题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1048
经验:卡在这题,主要是运行过程发生错误,其实还是挺简单的,数组设置的太少了。嗯,以后若出现runtime,就要检查数组是否越界以及是否使用了野指针,总之,和内存溢出很有关系。
我的代码:
#include<stdio.h>
#include<string.h>
int main()
{char buf[250],a[15],b[5];
char *p;
while(gets(a)&&strcmp(a,"ENDOFINPUT")!=0&&strcmp(a,"START")==0)
{gets(buf);
int k,i;
k=strlen(buf);
for(p=buf,i=0;i<k;i++,p++)
{if(*p<='E'&&*p>='A')*p=*p+21;
else if(*p>'E'&&*p<='Z')*p=*p-5;
}
gets(b);
puts(buf);
}
return 0;
}