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

why wa

Posted by Faker at 2008-10-17 11:02:07 on Problem 3157
#include<iostream>
using namespace std;
char s[300];
int n;
bool judge()
{   int i;
    if(s[0]>='A'&&s[0]<='Z')
       return 1;
    for(i=0;s[i]!='\0';i++)
    {  if(s[i]=='_'&&(s[i+1]>='z'||s[i+1]<='a'))
          return 1;
       
    }
    return 0;
}
int main()
{   scanf("%s",s);
    int i;
    bool flag=0;
    if(judge())
    {   printf("Error!\n");
        return 0;
    }
    for(i=0;s[i]!='\0';i++)
    {   if(flag==1)
        {  flag=0;
           continue;
        }
        
        if(s[i]=='_')
        {   
            {    printf("%c",s[i+1]-'a'+'A');
                 flag=1;
            }
        }
        else if(s[i]>='A'&&s[i]<='Z')
             {  printf("_%c",s[i]-'A'+'a');
             }
        else printf("%c",s[i]);
    }
    printf("\n");
    system("pause");
    return 0;
}

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