- public class TQC101
- {
- public static void main(String[] arg)
- {
- int r[]=new int[42];
- for(int i=0;i<42;i++)
- {
- r[i]=i+1;
- }
- for(int i=0;i<42;i++)
- {
- int rr=(int)(Math.random()*42);
- int t=r[i];
- r[i]=r[rr];
- r[rr]=t;
- }
- for(int i=0;i<6;i++)
- {
- System.out.printf("第%d個號碼:%02d\n",i+1,r[i]);
- }
- System.out.printf("特別號:%02d\n",r[6]);
- }
- }
複製代碼- import java.util.*;
- import java.text.*;
- public class TQC102
- {
- public static void main(String[] arg)
- {
- Date d=Calendar.getInstance().getTime();
- SimpleDateFormat sdf1=new SimpleDateFormat("yyyy/M/d a hh:mm");
- SimpleDateFormat sdf2=new SimpleDateFormat("yyyy/M/d a hh:mm:ss");
- SimpleDateFormat sdf3=new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
- SimpleDateFormat sdf4=new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");
- System.out.println(sdf1.format(d));
- System.out.println(sdf2.format(d));
- System.out.println(sdf3.format(d));
- System.out.println(sdf4.format(d));
- }
- }
複製代碼 |