- import java.util.Date;
- import java.util.Scanner;
- public class ch66
- {
- public static void main(String args[])
- {
- Scanner s=new Scanner(System.in);
- int answer;
- int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o;
- a=(int)(Math.random()*9)+1;
- b=(int)(Math.random()*9)+1;
- c=(int)(Math.random()*9)+1;
- d=(int)(Math.random()*9)+1;
- e=(int)(Math.random()*3)+2;
- f=(int)(Math.random()*9)+1;
- g=(int)(Math.random()*9)+1;
- h=(int)(Math.random()*9)+1;
- i=(int)(Math.random()*9)+1;
- j=(int)(Math.random()*9)+1;
- k=(int)(Math.random()*9)+1;
- l=(int)(Math.random()*9)+1;
- m=(int)(Math.random()*9)+1;
- n=(int)(Math.random()*9)+1;
- o=(int)(Math.random()*9)+1;
- System.out.pirntf("(%d+%d-%d+%d*%d)*%d*+%d+%d-%d-%d+(%d*%d)+(%d*%d+%d)= ",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o);
- long t1=new Date().getTime();
- answer=s.nextInt();
- long t2=new Date().getTime();
- System.out.print("你總共花了"+(t2-t1)+"毫秒思考,");
- if(answer==((a+b-c+d*e)*f*+g+h-i-j+(k*l)+(m*n+o)))
- {
- System.out.println("且答對了!");
- }
- else
- {
- System.out.println("且答錯了!");
- }
- }
- }
複製代碼 |