Home > Back-end >  In JAVA for you to note the double chromosphere
In JAVA for you to note the double chromosphere

Time:09-16

Package List.

import java.util.Random;
import java.util.Scanner;

Public class Caipiao {
Public static void main (String [] args) {

Int [] red=new int [6].
Int blue;

Int [] sysred=new int [6].
Int sysblue;

Int blueyes=0;
Int redyes=0;

The Random r=new Random ();

Scanner input=new Scanner(System.in);
Sysblue=r.n extInt (16);
//int [] rednum={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};

//randomly generated red balls
for (int i=0; i Sysred [I]=r.n extInt (33);
}

Sysblue=r.n extInt (16);


System. The out. Println (" the double chromosphere and purchasing the color ");
System. The out. Println (" please enter the red ball (6) : ");
for (int i=0; i Red [I]=input. NextInt ();
}

System. The out. Println (" please enter the basketball number: ");
Blue=input. NextInt ();

If (blue & gt; 16) {
System. The out. Println (" basketball than line: ");
}


//equal red ball + 1
for (int i=0; i <6; I++) {
If (sysred [I]==red [I]) {
Redyes=redyes + 1;
}
}
If (blue==sysblue) {
Blueyes=blueyes + 1;
}
If (blueyes==1 & amp; & Redyes==6) {
System. The out. Println (" congratulations you won the first prize in the ");
{} else if (redyes==6)
System. The out. Println (" congratulations you second prize in ");
} else if (blueyes==1 & amp; & Redyes={
=5)System. The out. Println (" congratulations you won third prize in ");
} else if (redyes==5 | | (blueyes==1 & amp; & Redyes==4)) {
System. The out. Println (" congratulations you zhong wanxie ");
} else if (redyes==4 | | (blueyes==1 & amp; & Redyes==3)) {
System. The out. Println (" congratulations you in five award, ");
} else if (redyes==3 | | blueyes==1) {
System. The out. Println (" congratulations you in six award, ");
} else if (blueyes==1) {
System. The out. Println (" congratulations you in six award, ");
} else {
System. The out. Println (" you didn't win ");
}
for (int i=0; i For (int j=0; J & lt; Sysred. -i length - 1; J++) {
If (sysred [j] & gt; Sysred [m + 1]) {
Int TMP=sysred [j + 1);
Sysred [j + 1)=sysred [j];
Sysred [j]=TMP;
}
}
}
System. The out. Println (" this winning number: ");
System. The out. Print (" red ball number: ");
for (int i=0; i System. The out. Println (sysred [I] + "");
}
System. The out. Println (" basketball number + sysblue ");
}
}

CodePudding user response:

Six award, still lack of three red balls, please help me to fill it

CodePudding user response:

There are a few problems:
1. Random red basketball will be equal to 0,
2. Generate six red balls may be repeated,
3. Generate six red balls if 28 to 30 5 12 September 13 is unordered, if I input the content of the 5 September 12 13 28 to 30, is completely different with the order of random but actually all have, is not the winning
4. Three red balls or the blue one is six, why judge again blue 1
 else if (redyes==3 | | blueyes==1) {
System. The out. Println (" congratulations you in six award, ");
} else if (blueyes==1) {
System. The out. Println (" congratulations you in six award, ");
}

Just
 else if (redyes==3 | | blueyes==1) {
System. The out. Println (" congratulations you in six award, ");
}
Or written
Else if (redyes==3) {
System. The out. Println (" congratulations you in six award, ");
} else if (blueyes==1) {
System. The out. Println (" congratulations you in six award, ");
}
  • Related