?? game1.java
字號:
import java.util.*;
import mypg.InputData;
class Game1{
public static int[] Game(int max,int N){
int index;
int[] a = new int[max];
Random test = new Random();
for(index=0; index<a.length; index++){
a[index]=index+1;
}
index--;
int tempIndex, tempCon;
for(; index>=0; index--){
tempIndex = test.nextInt(a.length);
tempCon = a[index];
a[index] = a[tempIndex];
a[tempIndex] = tempCon;
}
System.out.println("彩票開獎號碼:");
for(int i=0; i<N; i++){
System.out.print(a[i]+" ");
}
System.out.println();
return a;
}
public void game(){
int Number[] = new int [5];
int c[] = new int [21];
int count=0;
// c=Game(21,5);
System.out.println("請輸入五個位于0~22之間的數:");
for(int i=0;i<5;i++){
Number[i]=InputData.iRead();
};
c=Game(21,5);
for(int i=0;i<5;i++)
for(int j=0;j<5;j++)
if(Number[j]==c[i])
count++;
System.out.println("您買的彩票號碼:");
for(int i=0; i<5; i++){
System.out.print(Number[i]+" ");
}
System.out.println();
switch(count){
case 5:System.out.println("恭喜你中了一等獎!");
break;
case 4:System.out.println("恭喜你中了二等獎!");
break;
case 3:System.out.println("恭喜你中了三等獎!");
break;
default:System.out.println("很遺憾,本次你沒有中獎!");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -