为什么运行结果都是C

[复制链接]
查看11 | 回复2 | 2010-7-31 23:52:06 | 显示全部楼层 |阅读模式
#include
int main()
{

float score;

char grade;

printf("Please input the score:\n");

scanf("%.2f",&score);

grade=(score>=90.00?'A':(score>=60.00?'B':'C'));

printf("%c\n",grade);

return 0;
}
为什么scanf("%.2f",&score); 中f前多了.2,结果就不对了呢,去掉就可以了

回复

使用道具 举报

千问 | 2010-7-31 23:52:06 | 显示全部楼层
格式问题,输入时不能那么用,输出的时候可以那样用。
回复

使用道具 举报

千问 | 2010-7-31 23:52:06 | 显示全部楼层
#includeint main(){
float score;
char grade;
printf("Please input the score:\n");
scanf("%f",&score); printf("%.2f\n",score);
grade=score>=9
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行