Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
用gets()输出AC,用for循环字符逐个输入就Runtime Error。Why??求解#include<iostream> #include<string> using namespace std; int main() { char ch[500]; int i,len; while(1) { gets(ch); /* for(i=0;;i++){ 改用这里输入就Runtime Error scanf("%c", &ch[i]); if(ch[i]=='\n') { ch[i] = '\0'; break; } }*/ len=strlen(ch); if(!strcmp(ch,"START") || !strcmp(ch,"END")) continue; if(!strcmp(ch,"ENDOFINPUT")) break; for(i=0;i<len;i++) { if(ch[i]>'E' && ch[i]<='Z') printf("%c", ch[i]-5); else if(ch[i]>='A' && ch[i]<='E') printf("%c",ch[i]+21); else printf("%c", ch[i]); } printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator