35选7不重复
来源:互联网 发布:java经典书籍推荐 编辑:程序博客网 时间:2024/06/03 10:19
本程序用来从1到35个选出7个数字,并且不可重复
package com.hyan.test;import java.util.*;public class Random { public static void main(String[] args) { boolean a=arr(); if (a) { arr(); } } public static boolean arr() { int[] num=new int[35]; for(int i=0;i<num.length;i++){ num[i]=i+1; } int[] m=new int[7]; boolean flag=false; for(int i=0;i<m.length;i++){ int n=(int) (Math.random()*35); m[i]=num[n]; } int count=0; for (int j = 0; j < m.length; j++) { int temp=0; if (temp==m[j]) { count++; } } if (count>=2) { flag=true; }else{ System.out.println("没有重复"); System.out.println(Arrays.toString(m)); } return flag; }}
阅读全文
0 0
- 35选7不重复
- 随机选数 不重复
- 【day-7】组合-不重复
- 随机产生7个不重复的1-36之间的数。36选7
- 随机生成7个不重复的彩票号码 (33选7)
- 不重复质因子
- 不重复随机数(int)
- 不重复随机数(int)
- sql查询不重复
- 不重复顺序递归
- 不重复的随机数
- 查询不重复数据
- 产生不重复随机数
- 插入不重复数据
- 不重复数
- 插入不重复数据
- 不重复随机数
- 查询不重复字段
- 2016北航机试枚举类型转换
- js 浮点加减乘除
- 蓝桥杯 ADV-173 算法提高 淘淘的名单
- VMware + ubuntu 编译android7.0
- 阿里云linux上安装Java
- 35选7不重复
- DelephiForm的borderstyle
- 2 WebSocket
- 蓝桥杯 ADV-111 算法提高 Quadratic Equation
- javaee基础之servlet(一)
- Add Two Numbers--leetcode
- 二、web应用组织结构
- 通用的事件侦听器函数
- TypeScript模块整理(三)使用其他JavaScript库