public class 魏功豪_vector {
public static void main(String[] args) {
int betTimes = 10;
int balls = 49;
int temp;
for (int bt = 1; bt <= betTimes; bt++) {
java.util.Vector<Integer> allBalls = new java.util.Vector<Integer>();
for (int i = 0; i <= balls - 1; i++) {
allBalls.addElement(i + 1);
}
int [] arrSixBall = new int [6];
System.out.print("第" + bt + "注\t");
for (int times = 0; times < 6; times++) {
int randomTakeOneBall = (int)(Math.random()*allBalls.size());
arrSixBall[times] = (int)allBalls.get(randomTakeOneBall);
allBalls.remove(randomTakeOneBall);
}
for (int i = 0; i < 6; i++) {
for (int j = i; j < 6; j++) {
if (arrSixBall[i] < arrSixBall[j]) {
temp = arrSixBall[j];
arrSixBall[j] = arrSixBall[i];
arrSixBall[i] = temp;
}
}
}
for (int x = 0; x < 6; x++) {
System.out.print((arrSixBall[x] < 10) ? " " + arrSixBall[x] + ",\t" : arrSixBall[x] + ",\t");
}
System.out.print("\n");
}
}
}
沒有留言:
張貼留言