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 |
Re:Java解答In Reply To:Java解答 Posted by:leiliang_2013 at 2010-10-30 07:15:35 后面这部分我没看懂。能麻烦稍微讲解一下吗? > boolean dup = false; > int num = 1; > String first = arr.get(0); > int pointer = 1; > int arrSize = arr.size(); > while(pointer < arrSize) > { > if(first.equals(arr.get(pointer))) > { > num += 1; > pointer += 1; > if(pointer == arr.size()) > { > dup = true; > System.out.println(first.substring(0,3)+"-"+first.substring(3,7)+" "+num); > } > } > else > { > if(num > 1) > { > dup = true; > System.out.println(first.substring(0,3)+"-"+first.substring(3,7)+" "+num); > } > num = 1; > first = arr.get(pointer); > pointer += 1; > } > } > if(!dup) > System.out.println("No duplicates."); > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator