返回列表 發帖
  1. import java.util.Date;
  2. import java.util.Scanner;
  3. public class ch66
  4. {
  5.      public static void main(String args[])
  6.      {
  7.          Scanner s=new Scanner(System.in);
  8.          int answer;
  9.          int a,b,c,d,e,f,g,h,i,j,k,l;
  10.          a=(int)(Math.random()*9+1);
  11.          b=(int)(Math.random()*9+1);
  12.          c=(int)(Math.random()*9+1);
  13.          d=(int)(Math.random()*9+1);
  14.          e=(int)(Math.random()*9+1);
  15.          f=(int)(Math.random()*9+1);
  16.          g=(int)(Math.random()*9+1);
  17.          h=(int)(Math.random()*9+1);
  18.          i=(int)(Math.random()*9+1);
  19.          j=(int)(Math.random()*9+1);
  20.          k=(int)(Math.random()*9+1);
  21.          l=(int)(Math.random()*9+1);
  22.          System.out.printf("(((%d+%d)*%d-%d)+%d)*%d+(%d-%d)*%d*(%d+%d)*%d=",a,b,c,d,e,f,g,h,i,j,k,l);
  23.          long t1=new Date().getTime();
  24.          answer=s.nextInt();
  25.          long t2=new Date().getTime();
  26.          System.out.print("你總共花費了"+(t2-t1)+"毫秒思考,");
  27.          if(answer==((((a+b)*c-d)+e)*f+(g-h)*i*(j+k)*l))
  28.          {
  29.              System.out.print("且答對了!");
  30.          }
  31.          else
  32.          {
  33.              System.out.print("但答錯了!");
  34.          }

  35.      }
複製代碼

TOP

返回列表