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 wc171170 at 2007-07-17 10:47:31 on Problem 3157
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:
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