HDU 1073 Online Judge (字符串处理,格式判断的好题!!!!)

来源:互联网 发布:自学漫画的软件 编辑:程序博客网 时间:2024/05/22 16:53


Problem Description
Ignatius is building an Online Judge, now he has worked out all the problems except the Judge System. The system has to read data from correct output file and user's result file, then the system compare the two files. If the two files are absolutly same, then the Judge System return "Accepted", else if the only differences between the two files are spaces(' '), tabs('\t'), or enters('\n'), the Judge System should return "Presentation Error", else the system will return "Wrong Answer".

Given the data of correct output file and the data of user's result file, your task is to determine which result the Judge System will return.
 

Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case has two parts, the data of correct output file and the data of the user's result file. Both of them are starts with a single line contains a string "START" and end with a single line contains a string "END", these two strings are not the data. In other words, the data is between the two strings. The data will at most 5000 characters.
 

Output
For each test cases, you should output the the result Judge System should return.
 

Sample Input
4START1 + 2 = 3ENDSTART1+2=3ENDSTART1 + 2 = 3ENDSTART1 + 2 = 3ENDSTART1 + 2 = 3ENDSTART1 + 2 = 4ENDSTART1 + 2 = 3ENDSTART1+2=3END
 

Sample Output
Presentation ErrorPresentation ErrorWrong AnswerPresentation Error
 

注意数组清零,此处wa2发


#include<iostream>#include<cstring>#include<cstdio>#include<algorithm>using namespace std;const int N=10000+10;char temp[N];char a1[N],a2[N],b1[N],b2[N];void input(char a[],char b[]){gets(temp);while(strcmp(temp,"START")!=0) gets(temp);while(gets(temp)) {if(strcmp(temp,"END")==0) break;if(strlen(temp)!=0)strcat(a,temp);strcat(a,"\n");}int k=0,n=strlen(a);for(int i=0;i<n;i++) {if(a[i]!=' ' && a[i]!='\t' && a[i]!='\n') b[k++]=a[i];}b[k]='\0';}int main(){int t;scanf("%d",&t);while(t--) {a1[0]=a2[0]=b1[0]=b2[0]='\0';input(a1,b1);input(a2,b2);if(strcmp(a1,a2)==0) printf("Accepted\n");else if(strcmp(b1,b2)==0) printf("Presentation Error\n");else printf("Wrong Answer\n");}return 0;}




0 0
原创粉丝点击