注册 登录
编程论坛 C++教室

[求助]大家帮忙看看我这段程序有什么错误

wwuusong 发布于 2007-03-22 19:45, 455 次点击
请大家看看我这段代码有什么错误
错在哪里
怎么改正
谢谢了
……

#include"stdio.h"
main()
{
int score;
char grade;
printf("\nplease input a student score:");
scanf("%f",&score);
if(score>100||score<0)
printf("\ninput error!");
else
{if(score>=90)
grade='A';
else
{if(score>=70)
grade='B';
else
{if(score>=60)
grade='C';
else grade='E';
}
}
}
printf("\nthe student grade:%c",grade);
}
8 回复
#2
freeforever2007-03-22 20:20
float score;
#3
wwuusong2007-03-22 20:24

大哥
什么意思啊???
我现在是大菜鸟的级别
很难看懂专业语言的
不好意思
请你详细的帮我解释
谢谢了

#4
freeforever2007-03-22 20:38
小弟,看好我来自哪了吧!

#include"stdio.h"
main()
{
int score;
char grade;
printf("\nplease input a student score:");
scanf("%f",&score);
if(score>100||score<0)
printf("\ninput error!");
else
{if(score>=90)
grade='A';
else
{if(score>=70)
grade='B';
else
{if(score>=60)
grade='C';
else grade='E';
}
}
}
printf("\nthe student grade:%c",grade);
}

这两句犯相了!!数据类型不一致了
#5
yuyunliuhen2007-03-22 20:39

都有什么错误提示?
#include"stdio.h"
void main()
{
int score;
char grade;
printf("\nplease input a student score:");
scanf("%d",&score);
if(score>100||score<0)
printf("\ninput error!");
else if(score>=90)
grade='A';
else if(score>=70)
grade='B';
else if(score>=60)
grade='C';
else grade='E';

printf("\nthe student grade:%c",grade);
}
用个CASE语句试试.

[此贴子已经被作者于2007-3-22 20:41:30编辑过]

#6
wwuusong2007-03-22 21:32
回复:(freeforever)小弟,看好我来自哪了吧!#incl...
呵呵
只是看到了不一样的地方
但是不知道是为什么……
见笑了……
#7
wwuusong2007-03-22 21:33
回复:(yuyunliuhen)都有什么错误提示?#include
呵呵
谢谢斑竹的详细指导!!!
以后再下遇到了什么问题还邀请你和各位大虾指点
再次谢谢你们!!!
#8
s2005910602007-03-25 23:52

#9
wfpb2007-03-26 15:13
把%f改成%d,%d表示整数,%f表示浮点数
1