Home > database >  I write code where there is a problem, I don't see, I hope you help me to look at it
I write code where there is a problem, I don't see, I hope you help me to look at it

Time:04-06

Experiment content mainly programming 35 selected 7 lottery sales process, note the number n of user input from the keyboard to buy lottery tickets, program randomly generated n note number and prints, every note number for 7 1 ~ 35 random integers, each note doesn't have a repeat number seven number, and the output, in order to output,
Package lotteryticket.
import java.util.Scanner;
Public class buyalotteryticket {
Public static void main (String [] args) {
Scanner sc=new Scanner (System. In);
Int num=(int) (Math. The random (35) + 1); System. The out. Print (" please enter a note to sell lottery number: ");
Int n=sc. NextInt ();
Int [] a=new int n [7];
for(int k=0; K{the for (int I=0; i<7. I++)
{num=(int) (Math. The random () * 35 + 1); A [I]=num;
for(int j=0; J{if (a [I] a [j])
{I -;
break;
}
}
}
}
For (int m=1; M<=(7); M++)
{if (m % 70)
System. The out. Println (a [m] + '\ n');
} sc. The close ();
}
}
I write what's the problem, the hope can give advice or comments

CodePudding user response:

Set to queue to process such as: aa={1,2,3,4,5,6,7,8,9,10.. 35} queue results: the Result={}
With the random random sequence in aa find a kicked a queue, then inserted into a Result, among them the sort of Result is simple and can help to determine the number when inserted inserted before or behind,
Finally, the Result is the Result of the queue

CodePudding user response:

I haven't learned this, can only use the most basic way to do it

CodePudding user response:

Don't know what's the matter, anyway, is to run out the correct results, don't know where is there a problem
  • Related