import?java.util.Scanner;
public?class?GuessNum?{
public?static?void?main(String[]?args)?
{
System.out.println("======猜数字游戏======n");
int?answer?=?(int)(Math.random()?*?200?+?1);
Scanner?sr?=?new?Scanner(System.in);
while(true)?{
System.out.print("请输入你猜的数字(1-200):");
int?in?=?sr.nextInt();
if?(in?>?answer)?{
System.out.println("猜大了!n");
}?else?if(in?<?answer){
System.out.println("猜小了!n");
}?else?{
System.out.println("恭喜你,才猜对了!!!n");
break;
}
}
sr.close();
}
}
免责声明:本平台仅供信息发布交流之途,请谨慎判断信息真伪。如遇虚假诈骗信息,请立即举报
举报