import java.util.*; |
import java.io.*; |
/** |
* java版猜数字 |
*/ |
public class CaiShuZi { |
public static void main(String[] args) throws IOException { |
Random a = new Random(); |
int num = a.nextInt( 100 ); |
System.out.println( "请输入一个100以内的整数:" ); |
for ( int i = 0 ; i <= 9 ; i++) { |
BufferedReader bf = new BufferedReader( new InputStreamReader( |
System.in)); |
String str = bf.readLine(); |
int shu = Integer.parseInt(str); |
if (shu > num) |
System.out.println( "太大了!" ); |
else if (shu < num) |
System.out.println( "太小了!" ); |
else { |
System.out.println( "恭喜你,猜对了!" ); |
if (i <= 3 ) |
System.out.println( "你是天才!" ); |
else if (i <= 6 ) |
System.out.println( "勉强过关!" ); |
else if (i <= 9 ) |
System.out.println( "你还挺笨!" ); |
else |
System.out.println( "你太笨了!" ); |
break ; |
} |
} |
} |
} |