码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 1073 字符串处理

时间:2015-04-18 10:01:55      阅读:103      评论:0      收藏:0      [点我收藏+]

标签:

题意:给一系列的输出和标准答案,比较二者是AC,PE或WA

字符串处理还是比较薄弱,目前没什么时间搞字符串专题,所以遇到一题就努力搞懂

 1 #include<cstdio>
 2 #include<iostream>
 3 #include<algorithm>
 4 #include<cstring>
 5 #include<cmath>
 6 #include<queue>
 7 #include<map>
 8 using namespace std;
 9 #define MOD 1000000007
10 const double eps=1e-5;
11 #define cl(a) memset(a,0,sizeof(a))
12 #define ts printf("*****\n");
13 const int MAXN=6005;
14 char a1[MAXN],a2[MAXN],b1[MAXN],b2[MAXN];
15 int n,m,tt;
16 char temp[MAXN];
17 void in(char a[],char b[])
18 {
19     gets(temp);
20     while(strcmp(temp,"START")!=0)    gets(temp);   //START之前的都去掉
21     while(gets(temp))
22     {
23         if(strcmp(temp,"END")==0)   break;
24         if(strlen(temp)!=0) strcat(a,temp); //读入的不为换行符
25         strcat(a,"\n");
26     }
27     int t=0;
28     for(int i=0;i<strlen(a);i++)
29     {
30         if(a[i]!= &&a[i]!=\n&&a[i]!=\t)   //\t要加,因为题目中有要求,汗
31         {
32             b[t++]=a[i];
33         }
34     }
35     b[t]=\0;  //注意这个一定要加,否则没办法比较
36 }
37 int main()
38 {
39     int i,j,k;
40     #ifndef ONLINE_JUDGE
41     freopen("1.in","r",stdin);
42     #endif
43     scanf("%d",&tt);
44     while(tt--)
45     {
46         a1[0]=\0;
47         a2[0]=\0;
48         in(a1,b1);
49         in(a2,b2);
50         if(strcmp(a1,a2)==0)    printf("Accepted\n");       //未被删除格式前都相同,说明完全相同
51         else if(strcmp(b1,b2)==0)   printf("Presentation Error\n");
52         else printf("Wrong Answer\n");
53     }
54 }

 

hdu 1073 字符串处理

标签:

原文地址:http://www.cnblogs.com/cnblogs321114287/p/4436778.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!