Color Ball Code

Source: Internet
Author: User

1  PackageXuexi;2 31, generate system random number 6 Red 1 Blue42, receive the user select number 6 Red 1 Blue53The correct number of verification numbers64, announce the winning results7   8 @author Administrator9  Ten   One  A ImportJava.util.Random; - ImportJava.util.Scanner; -  the  Public classColor Ball { -  -      Public Static voidMain (string[] args) { -         int[] sr =New int[6]; Storage System generates red balls +         intSL = 0; Storage System-generated basketball -         int[] ur =New int[6]; Player-selected red ball +         intUL = 0; Player-Selected basketball A         intZH = 0; Correct number of red balls at         intZL = 0; The correct number of basketball -Random r =NewRandom (); Defining Arrays -         int[] RB = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, -28, 29, 30, 31, 32, 33 }; Specify the range of the array - Game Start - System.out.println (color ball game start, good luck); in         intindex = 0; -  to Generate system Number +          for(inti = 0; I sr.length; i++) { -              while(true) { theindex = R.nextint (33); *                 if(Rb[index]! = 0) { $Sr[i] =Rb[index];Panax NotoginsengRb[index] = 0; -                      Break; the                 } +             } A         } theSL = R.nextint (16) + 1; + receive user Selection number -SYSTEM.OUT.PRINTLN (Please select the red ball number; (1-33Please enter); $Scanner in =NewScanner (system.in); $          for(inti = 0; I ur.length; i++) { -Ur[i] =in.nextint (); -SYSTEM.OUT.PRINTLN (Please select the blue ball number; (1-16Please enter); theUL =in.nextint (); -         }Wuyi  the Verify if winning -  Wu          for(inti = 0; I sr.length; i++) { -              for(intj = 0; J Ur.length; J + +) { About                 if(Sr[i] = =Ur[i]) { $zh++; -                      Break; -                 } -  A             } +         } the         if(sr==ur) { -zl++; $              the         } the judging whether or not to win the         if(zh==6&&zl==1){ the System.out.println (Congratulations on your first prize 5 million);} -          in         Else if(zh==6&&zl==0){ the System.out.println (Congratulations on your second prize 100,000);} the         Else if(zh==5&&zl==1){ About System.out.println (Congratulations on the Third prize);} the         Else if(Zh==5 (zh==4&&zl==1)){ the System.out.println (Congratulations on your four prize);} the         Else if(Zh==4 (zh==3&&zl==1)){ + System.out.println (Congratulations on your five prizes);} -         Else if(zl==1){ the System.out.println (Congratulations on your six prize 5);}Bayi         Else{ the System.out.println (thank you for participating);} the Output Results - System.out.println (the red ball number for this period is); -          for(inti=0;isr.length-1;i++){ the              for(intj=0;jsr.length-1-i;j++){ the                 if(sr[j]sr[j+1]){ the                     intt=Sr[j]; theSr[j]=sr[j+1]; -sr[j+1]=T; the                      the                 } the             }94         } the System.out.println (the red ball number for this period is); the          for(inti=0;isr.length;i++); { theSystem.out.println (sr[i]+ );98         } About System.out.println (); -SYSTEM.OUT.PRINTLN (This period basketball number is +SL);101          for(inti=0;isr.length;i++); {102         103         104     } the     106     107}
color Ball Not completed

A problem occurs in the user output

Color Ball Code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.