mybatis-plus3.0.1列舉返回為null解決辦法
阿新 • • 發佈:2020-12-24
撲克牌隨機發牌技巧
撲克牌隨機發牌系統,除去大王小王
package modeal4;
import java.util.Scanner;
public class Zuoye3 {
public static void main(String[] args) { // 撲克牌隨機發牌系統 // 判斷輸入數字是否符合規則 int player; int card; Scanner sc = new Scanner(System.in); System.out.println("請輸入玩家數和每位玩家手牌數"); player = sc.nextInt(); card = sc.nextInt(); if (player > 52 || player < 1) { System.out.println("請輸入正確玩家數"); } if (player * card > 52) { System.out.println("發牌總數不能多於牌總數"); } /* * 定義牌的陣列,行標為花色,列標為大小 0為紅桃,1為黑桃,2為方片,3為梅花 */ int[][] a = new int[4][13]; for (int b = 0; b < 4; b++) { for (int c = 0; c < 13; c++) { a[b][c] = 0; } } // 隨機發牌 for (int players = 1; player > 0; player--, players++) { System.out.print("第" + players + "位玩家的牌為:"); for (int C = 0; C < card;) { int i = (int) (Math.random() * 4);// 花色 int j = (int) (Math.random() * 13);// 數字 if (a[i][j] != -1) { a[i][j] = -1; C++; // 花色 if (i == 0) { System.out.print("紅桃"); } if (i == 1) { System.out.print("黑桃"); } if (i == 2) { System.out.print("方片"); } if (i == 3) { System.out.print("梅花"); } // JQK if ((j + 1) < 11) { System.out.print((j + 1) + " "); } if ((j + 1) == 11) { System.out.print("J" + " "); } if ((j + 1) == 12) { System.out.print("Q" + " "); } if ((j + 1) == 13) { System.out.print("K" + " "); } } } System.out.println(); } }
}