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

Re:Java解答

Posted by bixiaoting at 2011-03-13 21:08:07 on Problem 1002
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:
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