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

终于成功了 小庆祝一下

Posted by talabanr at 2007-12-02 01:05:59 on Problem 1001
public String cutHeads(String mm)     //去掉String首部的 空格 和 0
	{
		for(int i=0;i<=100;i++){
			
			if(mm.startsWith(" "))
				mm=mm.substring(1);
			if((mm.length()==2||mm.length()==1)&&mm.startsWith("0")&&mm.endsWith("0"))
			{
				mm="0";
				continue;
			};
			if(mm.startsWith("0"))
				mm=mm.substring(1);
		}
		return mm;
	}
	public String cutTails(String mm)      //去掉String末尾的多余的 0 和小数点
	{
		if(mm.indexOf(".")!=-1)
			for(int i=0;i<=100;i++)
			{
				if(mm.endsWith("0"))
					mm=mm.substring(0, mm.length()-1);
			}
		if(mm.endsWith("."))
			if(mm.startsWith("."))
			{
				mm="0";
			}
			else
			{
				mm=mm.substring(0,mm.length()-1);
			}
		return mm;
	}
	

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