我这个程序是不是有问题啊 。如果用if else 语句编这个程序该咋编啊
scanf("%f",&x);
#include<stdio.h>
int main() {
float x;
printf("enter score:\n");
scanf("%f", &x);
if(x < 60)
printf("E");
else if(x < 70)
printf("D");
else if(x < 80)
printf("C");
else if(x < 90)
printf("B");
else if(x <= 100)
printf("A");
else
printf("wrong");
return 0;
}
你定义x为int型,scanf()中应该用%d而不是%f
int x;
scanf("%d",&x);
if(x<60)
printf("E");
else if(x>60&&x<70)
printf("D");
else if(x>70&&x<80)
printf("C");
else if(x>80&&x<90)
printf("B");
else if(x>90)
printf("A");