加载中...

浙江理工大学入队200题——13H

问题 H: 零基础学C/C++143——绝对公正的裁判

题目

现在,要求如果输入一个缩写短语,要求输出原型,具体看样例。

输入

The first line is integer T(T <= 20), the number of test cash case 第一行为一个数T(T<=20),为测试数据的数目 接下来,有T行分别输入一个缩写(缩写只包括AC,PE,WA,RE,TLE,MLE,OLE,CE)

输出

对于每组测试数据输出一行为着这缩写的原型

样例输入 Copy

8
AC
PE
WA
RE
TLE
MLE
OLE
CE

样例输出 Copy

Accepted
Presentation Error
Wrong Answer
Runtime Error
Time Limit Exceeded
Memory Limit Exceeded
Output Limit Exceeded
Compilation Error

题解

本题考查判断字符串是否相等,使用strcmp,如不清楚>https://www.runoob.com/cprogramming/c-function-strcmp.html<

代码(AC)

点击查看代码
#include <iostream>
#include <cstdio>
#include <cstring>
int main (){
	int t;
	scanf("%d",&t);
	char a[5];
	getchar();
	for(int i=0;i<t;i++)
	{
		scanf("%s",&a);
		if(strcmp(a,"AC") == 0) printf("Accepted\n");
		if(strcmp(a,"PE") == 0) printf("Presentation Error\n");
		if(strcmp(a,"WA") == 0) printf("Wrong Answer\n");
		if(strcmp(a,"RE") == 0) printf("Runtime Error\n");
		if(strcmp(a,"TLE") == 0) printf("Time Limit Exceeded\n");
		if(strcmp(a,"MLE") == 0) printf("Memory Limit Exceeded\n");
		if(strcmp(a,"OLE") == 0) printf("Output Limit Exceeded\n");
		if(strcmp(a,"CE") == 0) printf("Compilation Error\n");	
	}
	return 0;
}
posted @ 2022-10-29 19:44  shany212  阅读(18)  评论(0编辑  收藏  举报