題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=1073
資料判斷,主要是如何判斷WA和PE,吸收字元!
代碼:
1 #include <stdio.h>
2 #include <string.h>
3 #include <math.h>
4 #include <algorithm>
5 #include <iostream>
6 #include <ctype.h>
7 #include <iomanip>
8 #include <queue>
9 #include <stdlib.h>
10 using namespace std;
11
12 char tmp[5050];
13
14 void shuru(char p[])
15 {
16 getchar();
17 gets(tmp);
18 while(gets(tmp))
19 {
20 if(strcmp(tmp,"END")==0) break;
21 if(strlen(tmp)!=0) strcat(p,tmp);
22 strcat(p,"\n");
23 }
24 }
25
26 void duibi(char a[]){
27 int k=0;
28 for(int i=0;a[i];i++){
29 if(a[i]==' '||a[i]=='\t'||a[i]=='\n')
30 continue;
31 else
32 a[k++]=a[i];
33 }
34 a[k]='\0';
35 }
36
37 int main()
38 {
39 int n;
40 char a[5050];
41 char b[5050];
42 while(~scanf("%d",&n)){
43 while(n--){
44 a[0]='\0';
45 b[0]='\0';
46 shuru(a);
47 shuru(b);;
48 if(strcmp(a,b)==0){
49 cout<<"Accepted"<<endl;
50 continue;
51 }
52 else{
53 duibi(a);
54 duibi(b);
55 if(strcmp(a,b)==0){
56 puts("Presentation Error");
57 continue;
58 }
59 }
60 puts("Wrong Answer");
61 }
62 }
63 return 0;
64 }