题目来源:
http://acm.hdu.edu.cn/showproblem.php?pid=1073
Time Limit: 2000/1000 MS
(Java/Others) Memory Limit: 65536/32768 K
(Java/Others)
Total Submission(s):
4684 Accepted Submission(s):
1787
代码如下:
1 #include<iostream> 2 #include<stdio.h> 3 #include<string> 4 #include<string.h> 5 #include<map> 6 #include<math.h> 7 #include<algorithm> 8 #define N 5020 9 using namespace std; 10 void input(char *s) 11 { 12 char tmp[N]; 13 while(gets(tmp) && strcmp(tmp,"END")) 14 { 15 if(strlen(tmp)) strcat(s,tmp); 16 strcat(s,"\n"); 17 } 18 } 19 void Delchar(char *s,int len) 20 { 21 char tmp[N]; 22 int t=0; 23 for(int i=0;i<len;i++) 24 { 25 if(s[i]!= ‘ ‘ && s[i]!= ‘\t‘ && s[i] != ‘\n‘) 26 tmp[t++]=s[i]; 27 } 28 tmp[t]= ‘\0‘; 29 strcpy(s,tmp); 30 } 31 int main() 32 { 33 int t; 34 scanf("%d",&t); 35 getchar(); //不能少 ,获得 输入的数字后的 回车 36 while(t--) 37 { 38 char str1[N]; 39 char str2[N]; 40 memset(str1,0,sizeof(str1)); 41 memset(str2,0,sizeof(str2)); 42 int len1,len2; 43 input(str1); 44 input(str2); 45 len1=strlen(str1); 46 len2=strlen(str2); 47 if(len1 == len2 && !strcmp(str1, str2)){ 48 printf("Accepted\n"); 49 continue; 50 } 51 Delchar(str1,len1); 52 Delchar(str2,len2); 53 if(!strcmp(str1,str2)) 54 puts("Presentation Error"); 55 else 56 puts("Wrong Answer"); 57 58 } 59 60 return 0 ; 61 }
hdu 1073 字符串函数的应用,布布扣,bubuko.com
原文:http://www.cnblogs.com/zn505119020/p/3584047.html