c++程序—switch分支
#include<iostream> using namespace std; #include<string> int main() { //多元分支 cout << "请输入学生的分数:" << endl; int score; cin >> score; cout << "您输入学生的分数为:" << score << endl; if (score <= 100 && score >= 0) { switch (score / 10) { case 10:; case 9:cout << "该学生成绩优异" << endl; break; case 8:; case 7:cout << "该学生成绩良好" << endl; break; case 6:cout << "该学生成绩及格" << endl; break; default:cout << "该学生成绩不及格,明年再战" << endl; break; } } else cout << "请重新输入正确的分数" << endl; system("pause"); return 0; }