刚接触C++的小白求大神指点,为什么我的这段程序总是运行到一半就不动了?
#include<iostream>#include<string>usingnamespacestd;intscore;intcingrade(){cout<<"已输入...
#include <iostream>
#include <string>
using namespace std;
int score;
int cingrade() {
cout << "已输入考生成绩" << score << "分" << endl;
return score;
}
void showgrade() {
cout << "该考生成绩为" << score << endl;
}
void deletegrade() {
score = 0;
cout << "该考生成绩已删除" << endl;
void showgrade(int score);
}
int main() {
int a; string n;
string choice;
char Q;
cout << "菜单选项" << endl;
cout << "A.输入成绩" << endl;
cout << "B.显示成绩" << endl;
cout << "C.删除成绩" << endl;
cout << "请输入学生名字(输入完成按回车)和成绩(输入完成按回车)" << endl;
cin >> n >> a;
cout << "已输入考生"<<n<<"成绩" << a << "分" << endl;
cout << "请输入选项,输入Q退出" << endl;
cin >> choice;
while (choice != "Q") {
if (choice == "A") {
cin >> a>>n;
cout<<cingrade();
break;
}
else if (choice == "B") {
cin >> a >> n;
showgrade();
break;
}
else if (choice == "C") {
cin >> a >> n;
deletegrade();
break;
}
cout << "请输入选项,输入Q退出" << endl;
cin >> choice;
}
return 0;
} 展开
#include <string>
using namespace std;
int score;
int cingrade() {
cout << "已输入考生成绩" << score << "分" << endl;
return score;
}
void showgrade() {
cout << "该考生成绩为" << score << endl;
}
void deletegrade() {
score = 0;
cout << "该考生成绩已删除" << endl;
void showgrade(int score);
}
int main() {
int a; string n;
string choice;
char Q;
cout << "菜单选项" << endl;
cout << "A.输入成绩" << endl;
cout << "B.显示成绩" << endl;
cout << "C.删除成绩" << endl;
cout << "请输入学生名字(输入完成按回车)和成绩(输入完成按回车)" << endl;
cin >> n >> a;
cout << "已输入考生"<<n<<"成绩" << a << "分" << endl;
cout << "请输入选项,输入Q退出" << endl;
cin >> choice;
while (choice != "Q") {
if (choice == "A") {
cin >> a>>n;
cout<<cingrade();
break;
}
else if (choice == "B") {
cin >> a >> n;
showgrade();
break;
}
else if (choice == "C") {
cin >> a >> n;
deletegrade();
break;
}
cout << "请输入选项,输入Q退出" << endl;
cin >> choice;
}
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询