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 |
求WA数据。# include <stdio.h> # include <string.h> char ot[201],it[101]; int main(){ int i,k,len; bool ul,up; while(scanf("%s",it)!=EOF){ len=strlen(it); up=ul=false; if(it[0]<='Z'||it[len-1]=='_') { puts("Error!"); continue; } for(i=0;i<len;i++){ if(it[i]=='_'){ if(up) break; ul=true; if(i<len-1&&it[i+1]=='_') break; }else if(it[i]<='Z'){ if(ul) break; up=true; } } if(i<len){ puts("Error!"); continue; } if(!ul&&!up){ puts(it); continue; }else if(ul){ //C++-->Java k=0; for(i=0;i<len;i++){ if(it[i]=='_'){ up=true; continue; } if(up){ ot[k++]=it[i]-32; up=false; }else{ ot[k++]=it[i]; } } ot[k]='\0'; }else{ //Java-->C++ k=0; for(i=0;i<len;i++){ if(it[i]<='Z'){ ot[k++]='_'; ot[k++]=it[i]+32; }else{ ot[k++]=it[i]; } } ot[k]='\0'; } puts(ot); } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator