import java.util.Scanner;
import java.util.Random;
class Gusse
{
Scanner sc = new Scanner(System.in);
Random r = new Random();
int a = r.nextInt(100);
public void gusse()
{
for(int x = 1;x<=5;x++){
int b = sc.nextInt();
if (a>b)
{
System.out.println("你输入的数小了"+"\t第"+x+"次");
}
else if (a<b)
{
System.out.println("你输入的数大了"+"\t第"+x+"次");
}
else
{
System.out.println("恭喜你猜中了"+"\t第"+x+"次");
break;
}
if(x == 5)
{
System.out.println("三次机会已经没有了,请选择其他游戏玩吧!");
System.out.println();
}
}
}
}
|
|