本帖最後由 許逸瑋 於 2012-4-14 10:48 編輯
- W4 Y+ {5 p% V- U) k2 S @- TQC101
- public class TQC101
- {
- public TQC101() {}
- public static void main(String[] args)
- {
- int num[];
- num=new int[8];
- int i,j;
- i=1;
- do{
- num[i]=(int)(Math.random()*42) + 1;
- for( j = 1 ; j < i ; j++ ){
- if(num[i] == num[j])
- continue;
- }
- i++;
- }while( i<8 );
- for ( i = 1; i < 7 ; i++ ){
- if( num[i] < 10 )
- System.out.println("第"+i+"個號碼:0"+num[i]);
- else
- System.out.println("第"+i+"個號碼:"+num[i]);
- }
- if( num[7] < 10 )
- System.out.println("特別號:0"+num[i]);
- else
- System.out.println("特別號:"+num[i]);
- }
- }
- TQC102
- import java.util.*;
- import java.text.*;
- public class TQC102 {
- public static void main(String[] args) {
- Date date = 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日 a hh時mm分ss秒");
- SimpleDateFormat sdf4 =
- new SimpleDateFormat("yyyy年M月d日 E a hh時mm分ss秒 z");
-
- System.out.println("--------------------------");
- System.out.println(" 當地時間 ");
- System.out.println("--------------------------");
- System.out.println(sdf1.format(date));
- System.out.println(sdf2.format(date));
- System.out.println(sdf3.format(date));
- System.out.println(sdf4.format(date));
- }
- }
- TQC103
- import java.io.*;
- import java.util.Arrays;
- public class TQC103{
- public static void main(String args[]){
- try{
- int[] rdmNum;
- int inputNum;
- int i;
- final int bigNum = 1000;
- BufferedReader bin = new BufferedReader(
- new InputStreamReader(System.in));
- System.out.println("請輸入欲產生之亂數個數:");
- inputNum = Integer.parseInt(bin.readLine());
-
- rdmNum = new int[inputNum];
- for( i=0 ; i<inputNum ; i++ ){
- rdmNum[i] = (int)(Math.random()*bigNum) ;
- }
- Arrays.sort(rdmNum);
-
- for( i=0 ; i<inputNum ; i++ ){
- System.out.print( rdmNum[i] + "\t" );
- }
- }catch(Exception e){
- }
- }
- }
複製代碼 |