题解 | #HTTP状态码#
知识点:
分支控制:分支控制
数据类型:map<int, string>
#include <iostream>
#include <map>
using namespace std;
int main() {
int code = 0;
map<int, string> state = {
{200, "OK"},
{202, "Accepted"},
{400, "Bad Request"},
{403, "Forbidden"},
{404, "Not Found"},
{500, "Internal Server Error"},
{502, "Bad Gateway"}
};
while (cin >> code) {
cout << state[code] << endl;
}
return 0;
}