标签:stat tin new static ann can rand java编程 ext
一个小游戏。。哈哈import java.util.Scanner;
public class Area
{
public static void main(String[] args)
{
int a=(int)(Math.random()*100);//随机函数
int answer = 110;
do
{
System.out.print("请猜一个数:");
Scanner input=new Scanner(System.in);
answer=input.nextInt();
if(a==answer)
System.out.print("您终于猜对了");
else if(a>answer)
System.out.print("您猜的数字偏低!\n");
else if(a<answer)
System.out.print("您猜的数字偏高!\n");
}while(a!=answer);
}
}
标签:stat tin new static ann can rand java编程 ext
原文地址:https://blog.51cto.com/14233078/2365630