蓝海豹

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

http://bbs.csdn.net/topics/360247647

 

import java.util.Random;

public class Test {
 public static void main(String[] args) throws Exception {
  int[] a = new int[36];
  int[] b = new int[7];
  for(int i = 0;i<a.length;i++){
   a[i]=i+1;
  }
  Random r = new Random();
  for(int i=0;i<7;i++){
   int x=r.nextInt(36-i);
   b[i] = a[x];
   int t = a[x];
   a[x]=a[a.length-1-i];
   a[a.length-1-i]=t;
  }
  for(int x :b){
   System.out.print(x+" ");
  }
 }
}

posted on 2013-05-13 16:21  蓝海豹  阅读(750)  评论(0编辑  收藏  举报