帮忙看一上这个如何不能输出 谢啦
帮忙看一下这个怎么不能输出 谢啦
#include<iostream>
using namespace std;
int main()//输入学生成绩 统计出各个分数段的学生人数并输出
{
int a1=0,
a2=0,
a3=0,
a4=0,
b=0;
float score;
cout<<"请输入学生成绩,输入# 结束:"<<endl;
int i=0;
do{
cin>>score;
score=(int)score;
if(score<0||score>100)
{
cout<<"输入错误!"<<endl;
return 0;
}
if(score<60)++b;
if(score>=60&&score<70)
++a4;
if(score>=70&&score<80)
++a3;
if(score>=80&&score<90)
++a2;
if(score>90)
++a1;
++i;
}while(score!='#');
cout<<"总人数:"<<i<<endl;
cout<<"优秀:"<<a1<<endl;
cout<<"良好:"<<a2<<endl;
cout<<"中等:"<<a3<<endl;
cout<<"及格:"<<a4<<endl;
cout<<"不及格:"<<b<<endl;
cin.get();
return 0;
}
如题 不知道怎么就是运行的时候没办法输出 谢啦
------解决方案--------------------
while(score!='#') ???
float怎么跟一个char比较啊???、
------解决方案--------------------
cin>>score;如果输入一个#,这个socre是0值,不会是‘#’
------解决方案--------------------
while(cin);
#include<iostream>
using namespace std;
int main()//输入学生成绩 统计出各个分数段的学生人数并输出
{
int a1=0,
a2=0,
a3=0,
a4=0,
b=0;
float score;
cout<<"请输入学生成绩,输入# 结束:"<<endl;
int i=0;
do{
cin>>score;
score=(int)score;
if(score<0||score>100)
{
cout<<"输入错误!"<<endl;
return 0;
}
if(score<60)++b;
if(score>=60&&score<70)
++a4;
if(score>=70&&score<80)
++a3;
if(score>=80&&score<90)
++a2;
if(score>90)
++a1;
++i;
}while(score!='#');
cout<<"总人数:"<<i<<endl;
cout<<"优秀:"<<a1<<endl;
cout<<"良好:"<<a2<<endl;
cout<<"中等:"<<a3<<endl;
cout<<"及格:"<<a4<<endl;
cout<<"不及格:"<<b<<endl;
cin.get();
return 0;
}
如题 不知道怎么就是运行的时候没办法输出 谢啦
------解决方案--------------------
while(score!='#') ???
float怎么跟一个char比较啊???、
------解决方案--------------------
cin>>score;如果输入一个#,这个socre是0值,不会是‘#’
------解决方案--------------------
while(cin);