| - demand explanation
Find a poker other than a king size for each card only out of one, obtained by adding all of the possible 24 points
| - problem-solving ideas
| - Content Code
. 1 / ** 2 * 9527 :: @auther . 3 * @Description: . 4 * @program: Port . 5 * @Create: 2019-07-17 16:58 . 6 * / . 7 public class Equail24 { . 8 public static void main (String [] args) { . 9 Double SUM = 0; // record the total number of 10 Double COUNT = 0; // record the number of times become 24 points . 11 Double probability; // calculate the probability of 12 @ represents the variable i by hearts card number 13 for ( int. 1 = I; I <= 13 is; I ++ ) { 14 // number of cards to identify the variable j with the spade 15 for ( int j =. 1; j <= 13 is; j ++ ) { 16 // to use this variable k the number of card identification blocks . 17 for ( int K =. 1; K <= 13 is; K ++ ) { 18 is // with l this variable to identify plum number of cards . 19 for ( int l =. 1; l <= 13 is; l ++ ) { 20 is SUM = +. 1 ; 21 is IF (I + J + K + L == 24 ) { 22 is System.out.println ( "hearts" + I + "\ T" + 23 is "Spades" + J + "\ T" + 24 "box" + K + "\ T" + 25 "Plum" + l + "\ t" + " is the sum of 24 points" ); 26 is COUNT +. 1 = ; 27 } 28 29 } 30 31 is } 32 33 is } 34 is 35 } 36 Probability = COUNT / SUM * 100 ; 37 [ System.out.println ( "" ); 38 is System.out.println ( "four kinds of cards, one each from each of Poker, a total of 4 13 = 28561 kinds of power arrangement method," + 39 "the total number of aligned points is 24" + count + "\ n the probability of 24 points is routed "probability + +"% " ); 40 41 is } 42 is }
| - operating results