package suijishu;

import java.util.Random;

// TODO Auto-generated method stub

public class Xuanqi {

    public static void main(String[] args) {
// 36选7
int[] caiPiao = new int[5];
Random rand = new Random(); // 生成
for (int i = 0; i < 5; i++) // 生成7个随机数。i代表正在生成第几个数
{
int temp = rand.nextInt(36);
temp++; // 生成随机数
// 解决重复问题
int chongFuCiShu = 0; // 检索数组,记录重复次数
for (int j = 0; j < 5; j++) { // 检查是否有重复,有重复就记录chongFuCiShu++;
if (temp == caiPiao[j]) {
chongFuCiShu++;
}
} if (chongFuCiShu == 0) {
caiPiao[i] = temp;
} else {
i--;
}
// System.out.print(temp+"\t"); } // 显示
for (int i = 0; i < caiPiao.length; i++) {
System.out.print(caiPiao[i] + "\t");
} int[] lanQiu = new int[2];
Random rand1 = new Random(); for (int a = 0; a < 2; a++) // 生成7个随机数。i代表正在生成第几个数
{
int temp1 = rand1.nextInt(12);
temp1++; // 生成随机数
// 解决重复问题
int chongFuCiShu1 = 0; // 检索数组,记录重复次数
for (int b = 0; b < 2; b++) { // 检查是否有重复,有重复就记录chongFuCiShu++;
if (temp1 == lanQiu[b]) {
chongFuCiShu1++;
}
} if (chongFuCiShu1 == 0) {
lanQiu[a] = temp1;
} else {
a--;
}
// System.out.print(temp+"\t"); }
// 显示
for (int a = 0; a < lanQiu.length; a++) {
System.out.print(lanQiu[a] + "\t");
} } }

大乐透

大乐透  Java随机码-LMLPHP

05-11 10:48