很简单的,这段C程序哪里出了问题?

来源:百度知道 编辑:UC知道 时间:2024/05/25 00:33:59
#include<stdio.h>
main()
{int a;
printf("please enter the result\n");
scanf("%d",&a);
if (a<=100&&a>=90) A;
if (a<=89&&a>=80) B;
if (a<=79&&a>=70) C;
if (a<=69&&a>=60) D;
if (a<60) E;
printf("the level is:%c",a);
getch();
}
要求:输入一个百分制的成绩,要求输出等级:A,B,C,D,E

// fsa.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include<stdio.h>
main()
{
int a;
char result;
printf("please enter the result\n");
scanf("%d",&a);
if (a<=100&&a>=90) result = 'A';
if (a<=89&&a>=80) result = 'B';
if (a<=79&&a>=70) result = 'C';
if (a<=69&&a>=60) result = 'D';
if (a<60) result = 'E';
else resutl = "Z";
printf("the level is:%c\n",result);

}

最好用switch case

if (a<=100&&a>=90) A;
这样的语句修改为:
if (a<=100&&a>=90) a='A';

下面的语句类似修改,最后就能输出了。