hdu1073 Online Judge 一道字符串处理的水题,,wa了我一下午。

#include <stdio.h>#include <string.h>char ques[5010] , ans[5010] ,temp[5010];int main(){int t ;scanf("%d",&t) ;while(t–){bool pe = false , wa = false ;gets(temp) ;while(strcmp(temp,"START")!=0){gets(temp) ;}int len1 = 0 ;gets(temp) ;while(strcmp(temp,"END")!=0){if(strlen(temp) == 0){ques[len1++] = '\n' ;}else{strncpy(ques+len1,temp,strlen(temp)) ;len1 += strlen(temp) ;ques[len1++] = '\n' ;}gets(temp) ;}ques[len1] = '\0' ;gets(temp) ;while(strcmp(temp,"START")!=0){gets(temp) ;}int len2 = 0 ;gets(temp) ;while(strcmp(temp,"END")!=0){if(strlen(temp) == 0){ans[len2++] = '\n' ;}else{strncpy(ans+len2,temp,strlen(temp)) ;len2 += strlen(temp) ;ans[len2++] = '\n' ;}gets(temp) ;}ans[len2] = '\0' ;if(strcmp(ques,ans) == 0){puts("Accepted") ;}else{int i = 0 , j = 0 ;while(i<len1 && j<len2){if(ques[i]!=ans[j]){if(ques[i] == ' ' || ques[i] == '\t' || ques[i] == '\n'){while(ques[i] == ' ' || ques[i] == '\t' || ques[i] == '\n'){++i ;}pe = true ;}if(ans[j] == ' ' || ans[j] == '\t' || ans[j] == '\n'){while(ans[j] == ' ' || ans[j] == '\t' || ans[j] == '\n'){++j ;}pe = true ;}if(ques[i]!=ans[j]){wa = true ;break ;}}++i,++j ;}if(i<len1){while(ques[i] == ' ' || ques[i] == '\t' || ques[i] == '\n'){i++ ;}if(i<len1){wa = true ;}else{pe = true ;}}if(j<len2){while(ans[j] == ' ' || ans[j] == '\t' || ans[j] == '\n'){j++ ;}if(j<len2){wa = true ;}else{pe = true ;}}if(wa){puts("Wrong Answer") ;}else if(pe){puts("Presentation Error") ;}else{puts("Accepted") ;}}}return 0 ;}与君共勉

,无论如何,没有人有办法把自己抑或他人的刺拔掉。那是一碰便痛的软肋,

hdu1073 Online Judge 一道字符串处理的水题,,wa了我一下午。

相关文章:

你感兴趣的文章:

标签云: