- 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;
- a=(int)(Math.random()*90)+10;
- b=(int)(Math.random()*90)+10;
- c=(int)(Math.random()*90)+10;
- d=(int)(Math.random()*90)+10;
- System.out.printf("%d+%d+%d+%d= ",a,b,c,d);
- long t1=new Date().getTime();
- answer=s.nextInt();
- long t2=new Date().getTime();
- System.out.print("你總共花費了"+(t2-t1)+"毫秒思考, ");
- if(answer==((a+b-c*d/a))
- {
- System.out.println("且答對了!");
- }else
- {
- System.out.println("但答錯了!");
- }
- }
- }
複製代碼 |