import java.lang.*;
import java.util.*;
public class TQC101
{
int[] num;
public void init()
{
num = new int[42];
for(int i=0;i<42;i++)
num[i] = i+1;
}
public void random()
{
Random rnd = new Random((new Date()).getTime());
for(int i=0;i<42;i++)
{
int a = rnd.nextInt(42);
int b = rnd.nextInt(42);
int tmp = num[a];
num[a] = num[b];
num[b] = tmp;
}
}
public void showResult()
{
System.out.println("第1個號碼:"+String.format("%02d",num[0]));
System.out.println("第2個號碼:"+String.format("%02d",num[1]));
System.out.println("第3個號碼:"+String.format("%02d",num[2]));
System.out.println("第4個號碼:"+String.format("%02d",num[3]));
System.out.println("第5個號碼:"+String.format("%02d",num[4]));
System.out.println("第6個號碼:"+String.format("%02d",num[5]));
System.out.println("特別號:"+String.format("%02d",num[6]));
}
public static void main(String[] args)
{
TQC101 self = new TQC101();
self.init();
self.random();
self.showResult();
}
} |