数组内容为随机1~7,不重复
2015-09-29 16:55
260 查看
<pre name="code" class="java">package test; public class test { static int[] hanshu(int[] b,int n) { for(int i = n;n<b.length-1;n++) { b = b[n+1]; //free(b[b.length]); } return b;} public static void main(String[] agrs) { int[] arry = new int[7]; int[] a = new int[7]; int j; for(int i = 0; i<7;i++) {arry[i]=i; //System.out.print(arry[i]+" "); } int m = 0; int n =arry.length; for(int i = 0; i<7;i++) { j = (int)(Math.random()*10%(n--)); System.out.print(j+" "); a[m] =arry[j]; m++; int[] b; b = hanshu(arry,j); } System.out.println(); for(int i = 0 ;i<7;i++) System.out.print(a[i]+" "); } }
相关文章推荐
- 40亿个非负整数中找到没出现的数
- CRC校验之模2除法(学习笔记、备忘)
- MongoDB使用中的一些问题
- 学习笔记:发现一个IE版本判断的好方法
- Linux----mktemp命令的用法
- HDU 1754 I Hate It(线段树单点替换/区间最值)
- intltool 的安装!!
- get()函数读顺序文件(C/C++源程序)
- 【设计模式】依赖倒置原则
- 多个授权文件共存的正确方法
- jsp网页在线编辑器
- CSS3
- nyoj 最长公共子序列 36 (简单LCS模板)
- XML::Parser perl module is required for intltool错误
- jQuery复制表单元素
- A different object with the same identifier value was already associated wit
- MYSQL主从同步故障一例及解决过程!
- Solr 3.5 + Tomcat7 + mmseg4j + 搜狗词库 -配置并运行
- Flume学习8_Flume1.5.0入门:安装、部署、及flume的案例
- oracle中的to_char数字转换为字符串格式