Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求WA数据。

Posted by gzw_02 at 2008-07-11 12:10:56 on Problem 3157
# 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator