import java.util.Scanner;
class RandomDemo
{
public static void main(String [] args)
{
int i =(int)(Math.random()*100)+1;
//System.out.println(i);
int count =1;
while(true){
System.out.println("输入一个数:");
Scanner s = new Scanner(System.in);
int x = s.nextInt();
double d = Math.PI;
//double a = Math.ceil(15.8);
//System.out.println(a);
if (x>i)
{
System.out.println("输入的数大了!");
}
else if(x<i)
{
System.out.println("输入的数小了!");
}
else
{
System.out.println("恭喜你,猜中了!");
break;
}
count++;
if(count>3)
{
System.out.println("你输入的次数超过了3次!"+"*****"+" 教你一个知识点:PI="+d);
break;
}
}
}
}
|
|