没有别的意思,就是数一下switch case 语句
switch 里面只能是整数,不能是浮点数等其他类型
#include<iostream> using namespace std; int main() { int n; while(cin >> n) { switch(n) { case 200: cout << "OK" << endl;break; case 202: cout << "Accepted" << endl;break; case 400: cout << "Bad Request" << endl;break; case 403: cout << "Forbidden" << endl;break; case 404: cout << "Not Found" << endl;break; case 500: cout << "Internal Server Error" << endl;break; case 502: cout << "Bad Gateway" << endl;break; } } return 0; }