import java.util.Scanner;
import java.util.Random;
public class caishuzi {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int realnumber;
int num;
boolean c=true;
System.out.println("请开始猜数字(100以内):");
Scanner reader=new Scanner(System.in);
Random random=new Random();
realnumber=random.nextInt(100)+1;
while(c)
{
num=reader.nextInt();
if(num>realnumber)
{
System.out.println("猜大了");
}
else if(num<realnumber)
{
System.out.println("猜小了!");
}
else if(num==realnumber)
{
System.out.println("猜对了!");
c=false;
}
}
}
}
好久没发了,无论是C#还是JAVA都积攒了好几个。趁着假期发出去吧。。