C++编译正常,调试出现Debug Error(见图)
#include <iostream>using namespace std;
int main()
{
float score;
char grade;
cout <<"请输入学生成绩"<<'n';
cin >>score;
while (score>100||score<0)
{
cout <<"请重新输入"<<'n';
cin >>score;
}
switch (grade)
{
case'A':cout<<"90~100n";
case'B':cout<<"80~89n";
case 'C':cout<<"70~79n";
case 'D':cout<<"60~69n";
case'E':cout<<"<60n";
default:cout<<"errorn";
break;
}
cout << "score is"<<score<<",grade is"<<grade<<endl;
return 0;
}
调试出现下面情况
回答
你的代码很奇怪,一个是输入成绩,一个是输入字母的成绩,你要两者选其一
要么输入等级,输出成绩的范围
char grade = '';
cout << "请输入等级ABCDE";
cin >> grade;
或者输入成绩后,程序得到grade
if (score >= 90 && score <= 100)
grade = 'A';
else if (score >= 80 && score <= 89)
grade = 'B';
...
以上是 C++编译正常,调试出现Debug Error(见图) 的全部内容, 来源链接: utcz.com/a/31802.html