hdu1073 Online Judge

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1073


题解:首先比较原字符串,相同输出accepted,不同在比较字符串去除: ' ', '\t', '\n',一样输出Presentation Error,否则输出Wrong Answer.


#include <stdio.h>
#include <string.h>
#define MAXN 5002

char ans1[MAXN],ans2[MAXN];
char result1[MAXN],result2[MAXN];
char temp[MAXN];

void input(char *str1,char *str2)
{
	int k=0,len,i;
	//gets(temp);
	while(gets(temp)&&strcmp(temp,"END"))
	{
		if(strlen(temp)==0)
			strcat(str1,"\n");
		else
			strcat(str1,temp);
	}
	len=strlen(str1);
	for(i=0;i<len;++i)
	{
		if(str1[i]!=' '&&str1[i]!='\t'&&str1[i]!='\n')
			str2[k++]=str1[i];
	}
	str2[k]='\0';
}

int main()
{
	int test;
	scanf("%d",&test);
	while(test--)
	{
		ans1[0]=result1[0]='\0';
		input(ans1,ans2);
		input(result1,result2);
		if(strcmp(ans1,result1)==0)
			printf("Accepted\n");
		else if(strcmp(ans2,result2)==0)
			printf("Presentation Error\n");
		else
			printf("Wrong Answer\n");
	}
	return 0;
}


你可能感兴趣的:(hdu1073 Online Judge)