package Demo3;
import java.util.Arrays;
import java.util.Random;
public class Guess {
public static void main(String[] args) throws InterruptedException {
Random r1 = new Random();
//摇红球
System.out.println("随机产生红球六个");
int [] red = new int[6];
for (int i = 0; i < red.length; i++) {
System.out.println("即将出来第"+(i+1)+"个球");
Thread.sleep(1000);
red[i] = r1.nextInt(33)+1;
System.out.println(red[i]);
}
Arrays.sort(red);
//摇蓝球
System.out.println("即讲开始摇蓝球");
Random r2 = new Random();
int blue = r2.nextInt(16)+1;
Thread.sleep(1000);
System.out.println(blue);
System.out.println("即将产生大奖");
Thread.sleep(3000);
System.out.print("红球:");
for (int i = 0; i < red.length; i++) {
if(i!=5)
System.out.print(red[i]+",");
else
System.out.print(red[i]);
}
System.out.println("蓝球:"+blue);
}
} |
|