| ||||||||||
| 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?import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[]a)
{
String in;
Scanner cin=new Scanner(System.in);
in=cin.nextLine();
String out="";
char type='n';
char c;
int at,l=in.length();
for(at=0;at<l;at++)
{
c=in.charAt(at);
if(!((c>='A'&&c<='Z')||(c>='a'&&c<='z')||c=='_'))
{
out="Error!";
break;
}
else if(c>='A'&&c<='Z')
{
if(type=='j'||at==0)
{
out="Error!";
break;
}
type='c';
c+=32;
out=out+"_"+c;
}
else if(c=='_')
{
if(type=='c'||at==0||at>l-2)
{
out="Error!";
break;
}
type='j';
while(c=='_')
{
at++;
if(at>l-1)
{
out="Error!";
System.out.println(out);
return;
}
c=in.charAt(at);
}
if(c>='A'&&c<='Z')
{
out="Error!";
break;
}
c-=32;
out+=c;
}
else
out+=c;
}
System.out.println(out);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator