⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 game1.java

📁 首先提示用户选择玩法 玩法1:21选5 输入5个数(从1
💻 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 + -