package csdn.net;
import java.util.Random;
import java.util.Scanner;
public class lianxi3YX {
public static void main(String[] args) {
Random r = new Random();
int i, c = 1;
i = r.nextInt(9);
System.out.println("请猜10以内的数字:");
while (true) {
Scanner number = new Scanner(System.in);
int f = number.nextInt();
if (c <= 3) {
c = c + 1;
if (f > 0 && f < 10) {
if (i > f) {
System.out.println("小了");
} else if (i < f) {
System.out.println("大了");
} else {
System.out.println("猜对了");
break;
}
} else {
System.out.println("超出范围了,笨蛋!");
}
} else {
System.out.println("3次都猜不出来...,笨的和肖志旭似得呢!");
break;
}
}
}
}
import java.util.Random;
import java.util.Scanner;
public class lianxi3YX {
public static void main(String[] args) {
Random r = new Random();
int i, c = 1;
i = r.nextInt(9);
System.out.println("请猜10以内的数字:");
while (true) {
Scanner number = new Scanner(System.in);
int f = number.nextInt();
if (c <= 3) {
c = c + 1;
if (f > 0 && f < 10) {
if (i > f) {
System.out.println("小了");
} else if (i < f) {
System.out.println("大了");
} else {
System.out.println("猜对了");
break;
}
} else {
System.out.println("超出范围了,笨蛋!");
}
} else {
System.out.println("3次都猜不出来...,笨的和肖志旭似得呢!");
break;
}
}
}
}