- public class SuanFa {
- public static void main(String[] args) {
- int[] arry=new int[98];
- ArrayList list=new ArrayList();
- //生成随机集合
- for(int i=0;i<10000;i++){
- int tem=new Random().nextInt(100);
- if(list.contains(tem)){
- continue;
- }
- list.add(tem);
- if(list.size()==98)
- break;
- }
- //把集合中的数据赋给数组
- for(int j=0;j<arry.length;j++){
- arry[j]=Integer.parseInt(list.get(j)+"");
- if(j%10==0){
- System.out.println();
- }
- System.out.print(arry[j]+",");
- }
- System.out.println();
- System.out.println("数组中不包含的两个数据是:");
- //查看数组里面不包含0-99中的那2个数据,打印出来
- for(int z=0;z<100;z++){
- if(list.contains(z))
- continue;
- System.out.print(z+",");
- }
- }
- }
- 运行结果:
- 15,79,77,19,84,31,69,3,73,38,
- 76,61,87,56,97,10,93,27,81,29,
- 94,59,71,53,20,66,30,89,6,42,
- 25,78,9,44,86,4,8,98,75,80,
- 16,2,85,74,82,11,68,58,46,28,
- 51,22,33,35,24,62,92,70,95,23,
- 99,32,5,34,14,43,96,47,41,1,
- 67,36,50,13,7,54,0,63,52,83,
- 49,55,26,12,18,91,45,88,39,48,
- 21,57,64,37,17,40,65,60,
- 数组中不包含的两个数据是:
- 72,90,
复制代码 |