- //小游戏36选7
- class Game03 {
- public static void main(String[] args) {
- int[] arr = new int[7];
- int num;
- int n = 1;
- arr[0] = (int)(Math.random() * 36) +1 ;
- w:while(true) {
- num = (int)(Math.random() * 36) +1 ;
- for (int i = 0;i < n ;i++ ) {
- if(num == arr[i]) {
- continue w;
- }
- }
- arr[n] = num;
- n++;
- if(n > 6) {
- break;
- }
- }
- System.out.println("本期36选7的中奖号码是:");
- for (int i = 0;i < 7 ;i++ ) {
- if(i != 6) {
- System.out.print(arr[i]+",");
- }
- else {
- System.out.println(arr[i]);
- }
- }
- }
- }
复制代码
|
|