hdu 1073 Online Judge(4)
来源:互联网 发布:sql2000数据库置疑修复 编辑:程序博客网 时间:2024/04/29 09:00
比赛时看大家都把这道题给做了,我就去看了,有思路,但没耐下心去做,现在看了别人的思路,我靠,和我当时想的一样!就想打自己几下。。。。现在又去调了,才发现好多地方以前我还是没注意到,有些是我不理解的,比如,数组a和b不初始化会出错(第一次忘了是字符型,初始化成memset(a,0,sizeof(a)),但是错了,不能理解),第19行中,for循环里的i范围为i<=k而不是i<k,还有40行中a[i]!='\0'而不是a[i]!='\n'。。。做完后想了想,还好没打。。
对于这种类型的题目,涉及输入时有多行的,总感觉有些地方是我的盲区,现在又不知道去哪照找相关的东西。。。郁闷中。。。
#include<stdio.h>#include<string.h>#include<stdlib.h>int main(){ int i,j,n,len1,len2,temp,k; char a[5005],b[5005],c[5005]; scanf("%d",&n); getchar(); while(n--) { gets(c); memset(a,'0',sizeof(a)); //注意 memset(b,'0',sizeof(b)); len1=0; while(gets(c),strcmp(c,"END")!=0) { k=strlen(c); for(i=0;i<=k;i++) ///注意 { a[len1]=c[i]; len1++; } } gets(c); len2=0; while(gets(c),strcmp(c,"END")!=0) { k=strlen(c); for(i=0;i<=k;i++) { b[len2]=c[i]; len2++; } } temp=0; for(i=0,j=0;i<=len1&&j<=len2;) { if(a[i]!=b[j]) if(a[i]==' '||a[i]=='\t'||a[i]=='\0') //注意 { i++; temp=1; } else if(b[j]==' '||b[j]=='\t'||b[j]=='\0') { j++; temp=1; } else { temp=2; break; } else { i++; j++; } } if(temp==0) printf("Accepted\n"); if(temp==1) printf("Presentation Error\n"); if(temp==2) printf("Wrong Answer\n"); } return 0;}
- hdu 1073 Online Judge(4)
- hdu 1073 Online Judge
- HDU 1073 Online Judge
- HDU 1073 Online Judge
- HDU 1073 Online Judge
- hdu 1073 Online Judge
- HDU 1073 Online Judge
- hdu 1073 Online Judge
- hdu 1073 Online Judge
- hdu 1073 Online Judge
- hdu 1073 Online Judge
- hdu 1073 Online Judge
- hdu 1073 Online Judge
- HDU 1073 Online Judge
- HDU 1073 Online Judge
- hdu 1073 Online Judge
- HDU 1073 Online Judge
- hdu 1073 Online Judge
- Command - xdc
- PHP 5.3.6源码编译过程中报错的处理
- Android画图Path的使用
- Map控件的简单使用
- 【软件自动化测试 - VBScript 5】== Get the recently createed Folder or a File in a Parent Folder
- hdu 1073 Online Judge(4)
- 关于学习基础学科与培养编程能力的问答
- Tomcat Oracle数据库连接池设置与使用
- iPhone, iPad, iPod – HTTP Live Streaming (HLS) with free tools on Windows
- java.lang.NoSuchMethodError: antlr.collections.AST.getLine()I 解决方法
- python与oracle(三)数据类型
- tomcat 配置ORACLE XE数据库连接池
- Proteus和Keil的使用与联调
- 交叉编译tslib1.4