- import java.util.*;
- public class HashMapTest{
- public static void main(String[] args){
- Random r = new Random();
- Set<Integer> set = new TreeSet<Integer>();
- int d=0;
- int n = 1;
- while(n<500){
- int a = r.nextInt(4)+1;
- int b = r.nextInt(4)+1;
- int c = r.nextInt(4)+1;
- if(a==b||a==c||b==c)
- continue;
- d=a*100+b*10+c;
- set.add(d);
- n++;
- }
- Iterator<Integer> iter = set.iterator();
- int n1 = 1;
- while(iter.hasNext()){
-
- System.out.print((int)iter.next()+",");
- if(n1%5==0)
- System.out.println();
- n1++;
- }
- System.out.println();
- System.out.println("总数:"+set.size());
- }
- }
复制代码 |