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 |
为什么第二组数据K会多一个呢?#include<iostream> #include<cstring> #include<cstdio> using namespace std; void deal(char *s) { char k[105]; for(int i=0;i<strlen(s);i++) { if('F'<=s[i]&&s[i]<='Z') k[i]=(char)(s[i]-5); else if('A'<=s[i]&&s[i]<='E') k[i]=(char)(s[i]+21); else k[i]=(char)s[i]; } getchar(); for(int i=0;i<strlen(s);i++)//这三行 cout<<k[i]; //是 cout<<endl; //AC的 //cout<<k<<endl; //换这个会错 } int main() { char s1[105],s2[105],s3[105]; while(1) { memset(s1,0,105); memset(s2,0,105); memset(s3,0,105); scanf("%s",s1); if(!strcmp(s1,"ENDOFINPUT")) break; getchar(); gets(s2); scanf("%s",s3); deal(s2); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator