/*8、 输入一个整数score代表分数,根据分数输出等级A-E (C语言编程题) A:90~100 B:80~89 C:70~79 D:60~69 E:0~60*/
#include <stdio.h>
int main() { int score; //定义score变量存储分数
printf("请输入您的分数1---100:");
scanf("%d",&score); //接收输入的分数
while (score<0||score>100) { //判断是否为有效分数
printf("无效的分数,请重新输入:");
scanf("%d",&score);
}
if (score>=90&&score<=100) { //A level
printf("your score level is A.\n");
}
else if (score>=80&&score<=89) { //B level
printf("your score level is B.\n");
}
else if (score>=70&&score<=79) { //C level
printf("your score level is C.\n");
}
else if (score>=60&&score<=69) { //D level
printf("your score level is D.\n");
}
else { //E level
printf("your score level is E.\n");
}
return 0;
}
如上 用了get函数接收字符串 但是运行时出现这个警告 warning: this program uses gets(), which is unsafe.
要怎么解决
|