java猜数游戏
package hello;
import java.util.Scanner;
public class hello {
private static Scanner in;
public static void main(String[] args) {
in = new Scanner(System.in);
int rad_num, guess, count = 0;
rad_num = (int)(1+Math.random()*(100));
guess = in.nextInt();
count++;
while(guess != rad_num)
{
if(guess < rad_num)
{
System.out.println("这个数小了");
}
else
{
System.out.println("这个数大了");
}
count++;
guess = in.nextInt();
}
System.out.println("恭喜你猜对了,用了"+ count+"次");
}
}