返回列表 發帖

TQC110 ~ TQC03做好的上傳

做好的上傳,謝謝
水桶小鄭,鯰魚

110
  1. import java.util.*;
  2. public class tqc110 {

  3.        
  4.         public static void main(String[] args) {
  5.                 int userIs = args.length/2;
  6.                
  7.                 boolean isuser =(userIs>0);
  8.                
  9.                 String[] q;
  10.                 String[] a;
  11.                
  12.                 if(isuser)
  13.                 {
  14.                         q=new String[userIs];
  15.                         a=new String[userIs];
  16.                         for(int i=0;i<args.length;i+=2)
  17.                         {
  18.                                 q[i/2]=args[i];
  19.                                 a[i/2]=args[i+1];
  20.                         }
  21.                 }else
  22.                 {
  23.                         q=new String[]{"電腦","資料庫","語法","學校","假期"};
  24.                         a=new String[]{"computer","DataBase","syntax","School","Vocation"};
  25.                 }
  26.                
  27.                 long startTime = new Date().getTime();
  28.                
  29.                
  30.                 System.out.println("請將下列中文詞彙換成英文單字!");
  31.                 System.out.println("輸入完成後請按Enter鍵:");
  32.                 Scanner s=new Scanner(System.in);
  33.                
  34.                 int right =0;
  35.                
  36.                 for(int i=0;i<q.length;i++)
  37.                 {
  38.                         System.out.println("第"+(i+1)+"題_"+q[i]);
  39.                         String user=s.next();
  40.                         user.toLowerCase();
  41.                         String ans =a[i].toLowerCase();
  42.                        
  43.                         if(user.equals(ans))
  44.                         {
  45.                                 System.out.println("Right!!");
  46.                                 right++;
  47.                         }else
  48.                         {
  49.                         System.out.println("No!!");       
  50.                         System.out.println("正確答案是:"+a[i]);
  51.                         }
  52.                         System.out.println();
  53.                 }
  54.                 long endTime = new Date().getTime();
  55.                 long use = (endTime-startTime)/1000;
  56.                 System.out.println("你使用了"+use+"秒,在"+q.length+"題中答對了"+right+"題");
  57.         }

  58. }
複製代碼
201
  1. import java.util.*;
  2. public class tqc201 {

  3.        
  4.         public static void main(String[] args) {
  5.                 Scanner s =new Scanner(System.in);
  6.                 System.out.print("請輸入Z的最大值");
  7.                 int z=Integer.parseInt(s.next());
  8.                
  9.                 int temp = 0;
  10.                 for(int x=1;x<100000;x++)
  11.                 {
  12.                         int y = 3*(x*x)+2*x+1;
  13.                         if(y>z)
  14.                         {
  15.                                 System.out.println("當X ="+(x-1)+"時, Y ="+temp+",Z="+z+",符合  Y > Z 的條件");
  16.                                 break;
  17.                         }
  18.                        
  19.                         temp=y;
  20.                 }
  21.         }

  22. }
複製代碼
202
  1. public class java202 {

  2.        
  3.        
  4.          
  5.         public static void main(String[] args) {
  6.                 float p = 1000;
  7.                 double r = 0.05 ;
  8.                 int n = 10 ;
  9.                 System.out.println("年"+"\t"+"A銀行(複利)"+"\t"+"B銀行(單利)");
  10.                 for(int i=1;i<=n;i++)
  11.                 {
  12.                         float m1=(float)(p*Math.pow(1+r,i));
  13.                         float m2=(float)(p*(1+i*r));
  14.                         System.out.printf("%d\t%.0f\t\t%.0f\n",i,m1,m2);
  15.                        
  16.                        
  17.                 }
  18.         }

  19. }
複製代碼
203
  1. import java.util.*;
  2. public class tqc203 {

  3.        
  4.         public static void main(String[] args) {
  5.                 if(args.length!=1)
  6.                 {
  7.                         System.out.println("參數戒務");
  8.                         return ;
  9.                 }               
  10.                 String str[] = args[0].split(",");
  11.                 System.out.println("隔開的字數是"+str.length);
  12.                 for(int i=0;i<str.length;i++)
  13.                 {
  14.                         System.out.println( (i+1)+","+str[i]);
  15.                 }       
  16.         }

  17. }
複製代碼
水桶小鄭,鯰魚

TOP

返回列表