BC69. HTTP状态码
描述
KiKi访问网站,得到HTTP状态码,但他不知道什么含义,BoBo老师告诉他常见HTTP状态码:200(OK,请求已成功),202(Accepted,服务器已接受请求,但尚未处理。)400(Bad Request,请求参数有误),403(Forbidden,被禁止),404(Not Found,请求失败),500(Internal Server Error,服务器内部错误),502(Bad Gateway,错误网关)。
输入描述
多组输入,一行,一个整数(100~600),表示HTTP状态码。输出描述
针对每组输入的HTTP状态,输出该状态码对应的含义,具体对应如下:示例1
输入:
200
输出:
OK
C 解法, 执行用时: 1ms, 内存消耗: 176KB, 提交时间: 2022-01-25
#include<stdio.h> int main() { int n; while(scanf("%d",&n)!=EOF) { switch(n) { case 200:printf("OK\n");break; case 202:printf("Accepted\n");break; case 400:printf("Bad Request\n");break; case 403:printf("Forbidden\n");break; case 404:printf("Not Found\n");break; case 500:printf("Internal Server Error\n");break; case 502:printf("Bad Gateway\n");break; default:break; } } return 0; }
C 解法, 执行用时: 1ms, 内存消耗: 176KB, 提交时间: 2021-12-14
#include <stdio.h> int main() { int input = 0; while(scanf("%d", &input) != EOF) { switch(input) { case 200: printf("OK\n"); break; case 202: printf("Accepted\n"); break; case 400: printf("Bad Request\n"); break; case 403: printf("Forbidden\n"); break; case 404: printf("Not Found\n"); break; case 500: printf("Internal Server Error\n"); break; case 502: printf("Bad Gateway\n"); break; } } return 0; }
C 解法, 执行用时: 1ms, 内存消耗: 176KB, 提交时间: 2021-12-13
#include <stdio.h> int main() { int state = 0; //多组输入 while (~scanf("%d", &state)) { switch (state) { case 200: printf("OK\n"); break; case 202: printf("Accepted\n"); break; case 400: printf("Bad Request\n"); break; case 403: printf("Forbidden\n"); break; case 404: printf("Not Found\n"); break; case 500: printf("Internal Server Error\n"); break; case 502: printf("Bad Gateway\n"); break; } } return 0; }
C 解法, 执行用时: 1ms, 内存消耗: 180KB, 提交时间: 2022-07-24
#include <stdio.h> int main(){ int num=0; while(scanf("%d",&num)!=EOF){ switch(num){ case 200: printf("OK"); break; case 202: printf("Accepted"); break; case 400: printf("Bad Request"); break; case 403: printf("Forbidden"); break; case 404: printf("Not Found"); break; case 500: printf("Internal Server Error"); break; case 502: printf("Bad Gateway"); break; } printf("\n"); getchar(); } return 0; }
C 解法, 执行用时: 1ms, 内存消耗: 180KB, 提交时间: 2022-04-23
#include<stdio.h> int main() { int n = 0; while( scanf("%d \n",&n) != EOF) { switch(n) { case 200 : printf("OK\n");break; case 202 : printf("Accepted\n");break; case 400 : printf("Bad Request\n");break; case 403 : printf("Forbidden\n");break; case 404 : printf("Not Found\n");break; case 500 : printf("Internal Server Error\n");break; case 502 : printf("Bad Gateway\n");break; } } return 0; }