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
{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 itCodePudding 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