KiKi访问网站,得到HTTP状态码,但他不知道什么含义,BoBo老师告诉他常见HTTP状态码:200(OK,请求已成功),202(Accepted,服务器已接受请求,但尚未处理。)400(Bad Request,请求参数有误),403(Forbidden,被禁止),404(Not Found,请求失败),500(Internal Server Error,服务器内部错误),502(Bad Gateway,错误网关)。
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状态,输出该状态码对应的含义,具体对应如下:
200-OK
202-Accepted
400-Bad Request
403-Forbidden
404-Not Found
500-Internal Server Error
502-Bad Gateway
200
OK
#include <stdio.h> int main() { int a = 0; while((scanf("%d",&a))!=EOF) { if ( a==200 ) printf("OK\n"); else if ( a ==202 ) printf("Accepted\n"); else if ( a ==400 ) printf("Bad Request\n"); else if ( a == 403 ) printf("Forbidden\n"); else if ( a ==404 ) printf("Not Found\n"); else if ( a== 500 ) printf("Internal Server Error\n"); else if ( a == 502 ) printf("Bad Gateway\n"); else printf("输入HTTP码有误,请重新输入\n"); } return 0; }
#include <stdio.h> int main() { int i = 0; while (scanf("%d", &i) != EOF) { switch (i) { 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; } } // }while(i==502?0:1); //当i = 502时,就会跳出循环,“错误网关” return 0; }
#include <stdio.h> enum { OK = 200, Accepted = 202, BadRequest = 400, Forbidden = 403, NotFound = 404, InternalServerError = 500, BadGateway = 502 }; int main() { int num = 0; int i = 0; while(scanf("%d", &num) != EOF) { switch(num) { case OK: printf("OK\n"); break; case Accepted: printf("Accepted\n"); break; case BadRequest: printf("Bad Request\n"); break; case Forbidden: printf("Forbidden\n"); break; case NotFound: printf("Not Found\n"); break; case InternalServerError: printf("Internal Server Error\n"); break; case BadGateway: printf("Bad Gateway\n"); break; default: printf("输入错误\n"); break; } } return 0; }
#include <stdio.h> int main() { int n = 0; 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; } } return 0; }
#include <stdio.h> int main() { int n = 0; 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: printf("输入错误\n"); break; } } return 0; }
#include <stdio.h> int main() { int n = 0; 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; } } return 0; }
#include <stdio.h> int main() { int HTTPstatus; while (scanf("%d", &HTTPstatus) != EOF) { switch (HTTPstatus) { 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: printf("Invalid Inpu!!!\n"); break; } } return 0; }
#include <stdio.h> int main() { int http=0; while((scanf("%d",&http))!=EOF){ http==200?printf("OK\n"):http==202?printf("Accepted\n"):http==400?printf("Bad Request\n"):http==403?printf("Forbidden\n"):http==404?printf("Not Found\n"):http==500?printf("Internal Server Error\n"):http==502?printf("Bad Gateway\n"):0;} }
#include<stdio.h> int main() { int a; while (scanf("%d",&a) != EOF) switch(a) { 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; }
#include<stdio.h> int main() { int http = 0; while (scanf("%d",&http) != EOF) switch(http) { 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; }
#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; } } return 0; }
#include<stdio.h> int main() { int a; while((scanf("%d",&a))!=EOF) { switch(a) { 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"); } }
#include <stdio.h> int main(){ typedef struct { int num; char arr[30]; } httpmap; httpmap arr[7] = {{200, "OK"}, {202, "Accepted"}, {400, "Bad Request"}, {403, "Forbidden"}, {404, "Not Found"}, {500, "Internal Server Error"}, {502, "Bad Gateway"}}; int num = 0; while(scanf("%d", &num) != EOF){ getchar(); for(int i = 0; i < 7; i++){ if(arr[i].num == num) printf("%s\n", arr[i].arr); } } return 0; }
#include<stdio.h> int main() { //法一 /* int arr[7]={200,202,400,403,404,500,502}; int i; for(i=0;i<7;i++) { scanf("%d\n",&arr[i]); switch(arr[i]) { 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; } } */ //法二 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; } } return 0; }