用记事本写,厉害!!!
import java.util.Scanner;
public class GuessNUber{
public static void main(String []args){
int i = 1,o = 0;
int magic = (int)(Math.random() * 101) + 100;
Scanner sr = new Scanner(System.in);
System.out.println("你尽管猜,猜对了算我输!");
int guess = sr.nextInt();
while(guess != magic){
if(guess > magic)
System.out.print("你猜大了!请重猜:(您已猜了" + i + "次)");
else
System.out.print("你猜小了!请重猜:(您已猜了" + i + "次)");
guess = sr.nextInt();
i++;
if(i == 3 && guess > 200 || i == 3 && guess < 100){
System.out.println("在下给你一点提示吧 这个数是100~200之间的");
o++;
}
else if(i == 6 && o == 0 && guess != magic){
int x = magic - 20;
int y = magic + 20;
if(x < 100)
x = 100;
if(y > 200)
y = 200;
System.out.println("给你一点提示吧这个数是" + x + "与" + y + "之间的数");
}
else if(i == 6 && o == 1 && guess != magic){
int x = magic - 20;
int y = magic + 20;
if(x < 100)
x = 100;
if(y > 200)
y = 200;
System.out.println("再给你一点提示吧这个数是" + x + "与" + y + "之间的数");
}
}
if(i <= 2)
System.out.print("是在下输了 的确是" + magic + " 但你猜了" + i + "次,已经很厉害了");
else if(i > 2 && i <= 5)
System.out.print("是在下输了 的确是" + magic + " 但你猜了" + i + "次,也还行");
else if(i > 5 && i <= 10)
System.out.print("是在下输了 的确是" + magic + " 但你猜了" + i + "次,很一般啊");
else
System.out.print("是在下输了 的确是" + magic + " 但你猜了" + i + "次,你是猪吗?你这个死垃圾 (O(∩_∩)O)");
}
}
做得不错!!! |