ImportJava.util.ArrayList;
ImportJava.util.Collections;
ImportJava.util.Random;
Import java.util.*;
PublicClassChoujiang {
Private arraylist<integer>Cards
PublicVOID Deal (IntNUM) {
if (cards==Null){
cards=New arraylist<integer>();
for (num=1;num<=100;num++){
Cards.add (num);
}
}
Collections.shuffle (cards);
}
PublicvoidDraw () {
Random ra=NewRandom ();
int s =Ra.nextint (Cards.size ());
System.out.println ("First prize:" +Cards.get (s));
Cards.remove (Cards.get (s));
Collections.shuffle (cards);
Forint i=0;i<2;i++){
int stwo=Ra.nextint (Cards.size ());
System.out.println ("Second Prize:" +Cards.get (Stwo));
Cards.remove (Cards.get (stwo));
}
Collections.shuffle (cards);
ForInt J =0;j<3;j++){
int sthree =Ra.nextint (Cards.size ());
System.out.println ("Third prize:" +Cards.get (SThree));
Cards.remove (Cards.get (SThree));
}
}
public static void main (string[] args) {
// TODO auto-generated Method stub
Choujiang C = new Choujiang ();
C.deal (0);
C.draw ();
}
}
< Span style= "color: #000000;" >< Span style= "color: #0000ff;" >< Span style= "color: #008000;" >< span>
Java Sixth job