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 |
终于成功了 小庆祝一下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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator