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<bits/stdc++.h>
using namespace std;
int main() {
string s[7] = {
"200-OK",
"202-Accepted",
"400-Bad Request",
"403-Forbidden",
"404-Not Found",
"500-Internal Server Error",
"502-Bad Gateway"
};
string in;
while(cin >> in) {
for(int i=0;i<7;i++) {
if(s[i].find(in)!=-1) {
cout << s[i].substr(4) << endl;
}
}
}
return 0;
} #include<iostream>
using namespace std;
int main()
{
int n;
while(cin >> n)
{
if (n == 200) cout << "OK" << endl;
else if (n == 202) cout << "Accepted" << endl;
else if (n == 400) cout << "Bad Request" << endl;
else if (n == 403) cout << "Forbidden" << endl;
else if (n == 404) cout << "Not Found" << endl;
else if (n == 500) cout << "Internal Server Error" << endl;
else if (n == 502) cout << "Bad Gateway" << endl;
}
} import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int num = sc.nextInt();
if(num == 200) System.out.println("OK");
if(num == 202) System.out.println("Accepted");
if(num == 400) System.out.println("Bad Request");
if(num == 403) System.out.println("Forbidden");
if(num == 404) System.out.println("Not Found");
if(num == 500) System.out.println("Internal Server Error");
if(num == 502) System.out.println("Bad Gateway");
}
}
} #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;
}
}
} import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Map<Integer,String> map = new HashMap<>(16);
map.put(200,"OK");
map.put(202,"Accepted");
map.put(400,"Bad Request");
map.put(403,"Forbidden");
map.put(404,"Not Found");
map.put(500,"Internal Server Error");
map.put(502,"Bad Gateway");
while (sc.hasNext()) {
int state = sc.nextInt();
System.out.println(map.get(state));
}
}
}
#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;
} import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while(scan.hasNext()) {
int state = scan.nextInt();
int[] httpstate = {200,202,400,403,404,500,502};
String[] result = {"OK","Accepted","Bad Request","Forbidden","Not Found","Internal Server Error","Bad Gateway"};
for(int i=0;i<httpstate.length;i++){
if(state == httpstate[i]){
System.out.println(result[i]);
break;
}
}
}
}
}
#include <stdio.h>
#include <math.h>
int main()
{
int HTTP;
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;
}
}
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 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;}
} import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
Map<Integer,String> type=new HashMap<>();
type.put(200,"OK");
type.put(202,"Accepted");
type.put(400,"Bad Request");
type.put(403,"Forbidden");
type.put(404,"Not Found");
type.put(500,"Internal Server Error");
type.put(502,"Bad Gateway");
while(sc.hasNextInt())
System.out.println(type.get(sc.nextInt()));
}
} import sys
d = {
200:"OK",
202:"Accepted",
400:"Bad Request",
403:"Forbidden",
404:"Not Found",
500:"Internal Server Error",
502:"Bad Gateway"
}
for line in sys.stdin:
a = int(line.strip())
print(d[a])