package com.wh.shuzu;

 import java.util.Arrays;

 /**
* 买彩票
* @author 丁璐同学
* 重复则重新遍历查询思想
*/
public class Lotery2 { public static void main(String[] args) {
int c[] = new int[5];
//先给数组全部赋值
for (int i = 0; i < c.length; i++) {
c[i] = (int) (Math.random() * 11 + 1);
}
//从第一个开始查询
for (int i = 0; i < c.length; i++) {
//从第二个开始查询
for (int j = i + 1; j < c.length; j++) {
//若相邻两个值重复,则给第二个元素重新赋一个随机数,并重新开始遍历查询是否有重复值
if (c[i] == c[j]) {
c[j] = (int) (Math.random() * 11 + 1);
i = 0;
j = i + 1;
} else {
continue;
} }
}
System.out.println(Arrays.toString(c)); }
}

最新文章

  1. jQuery外部框架浅析
  2. 当ListView有Header时,onItemClick里的position不正确
  3. 去哪儿网2017校招在线笔试(前端工程师)编程题及JavaScript代码
  4. swifter技巧(100)
  5. Lambda表达式之Python
  6. 12 Using_explain_plan
  7. u-boot 之配置分析 (2)
  8. POJ 3525 半平面交+二分
  9. 【原创】Linux下获取命令的帮助与常用命令
  10. iOS8 iPad Warning: Attempt to present &lt;UIImagePickerController:xxxx &gt; on xxxx which is already presenting (null)
  11. Spring Assert主张 (参议院检测工具的方法-主张)
  12. 运行指定路径下的exe
  13. Log4Net 常见格式说明(不断更新中)
  14. PHPNow升级PHP版本
  15. Windows10 中在指定目录下启动Powershell
  16. ubuntu代替方案
  17. centos7 部署 nginx+tomcat+MariaDB 环境并安装安全狗,使用natapp隧道
  18. Android java 多线程(三)
  19. MD5 加盐(Java)
  20. 【openjudge】【递推】例3.4 昆虫繁殖

热门文章

  1. ExpandableListView的使用以及信息的高亮显示
  2. Linux VPS/server上用Crontab来实现VPS自己主动化
  3. DB 查询分析器 6.03 ,遨游于不论什么Windows操作系统之上的最棒的数据库client工具
  4. 【转载】How browsers work--Behind the scenes of modern web browsers (前端必读)
  5. 深刻理解Java中形參与实參,引用与对象的关系
  6. http的session和cookie
  7. The uWSGI project aims at developing a full stack for building hosting services.
  8. netstat --numeric-ports -a -t -p 排查hadoop主从节点是否建立通信
  9. AOP 基本术语及其在 Spring 中的实现
  10. 并不对劲的bzoj2638