public int compare(int guess, int random){ if(guess==random){
System.out.println(\恭喜你,你猜对了\
System.out.println(\你猜对了. 你的得分是:\ return EQUALS; }else if(guess System.out.println(\你已经猜了\次了,你的数小了\ return LITTLE_THAN; }else{ count ; System.out.println(\你已经猜了\次了,你的数大了\ return GREATER_THAN; } } public static void main(String[] args){ GuessNum gn = new GuessNum(); Scanner scan = new Scanner(System.in); int num = gn.generateNum(); int guess; do{ System.out.println(\请输入一个10到99之间的数字\ guess = scan.nextInt(); } while(gn.compare(guess, num)!=GuessNum.EQUALS); } } 结果截图: 2)程序如下: import java.util.*; public class count { public static void main(String[] args) { int count = 0; List int temp = 0; for(int j = 1; j <= i; j ) { if(i %j == 0) { temp ;} } if(count < temp) { list.clear(); list.add(new Integer(i)); count = temp; } else if(count== temp) {list.add(new Integer(i));} i ; } for(int value: list) {System.out.println(\除数最多的数是: \除数个数为 :\ } } 结果截图: 3)程序如下: import java.io.*; import java.util.*; public class huochai { public static void main(String args[]) { System.out.print(\请按enter键开始游戏 \ byte[] buf2=new byte[20]; String strTemp3=\ try { System.in.read(buf2); } catch(IOException e){} strTemp3=new String(buf2); int a=(strTemp3.trim().compareTo(\ int b=(strTemp3.trim().compareTo(\ int amount=0; amount=(int)(Math.random()*31 20); if(a==0||b==0) System.out.print(\火柴数\ System.out.println(); System.out.print(\谁先拿1--人,2--计算机(1或2)?\ byte[] whoplay=new byte[20]; String strTemp2=\ try { System.in.read(whoplay); } catch(IOException e) {} strTemp2=new String(whoplay); int c=(strTemp2.trim().compareTo(\ int d=(strTemp2.trim().compareTo(\ int remain=amount; while(remain>=0) { if(c==0) { System.out.print(\人拿火柴\ double x=0; BufferedReader InputStreamReader(System.in)); try { String s= br.readLine(); x=Double.parseDouble(s); } catch(IOException e) { } if(x>=1&&x<=3) { remain-=(int)x; System.out.println(\剩余火柴数:\ if(remain==0) { System.out.print(\人赢!!\ if(remain<=3&&remain>0) { System.out.print(\计算机拿\ System.out.println(\计算机赢!!\ br=new BufferedReader(new } } else { System.out.println(\最多只能拿三根!\ continue; } System.out.print(\计算机拿\ int y=0; y=(int)(Math.random()*3 1); System.out.println(\ remain-=y; System.out.println(\剩余火柴数:\ if(remain==0) { System.out.print(\人赢!!\ } if(d==0) { System.out.print(\计算机拿\ int y=0; y=(int)(Math.random()*3 1); remain-=y; System.out.println(\ System.out.println(\剩余火柴数:\ if(remain==0) { System.out.print(\计算机赢!!\ break; } /* while(remain>=0) { System.out.print(\人拿火柴\ double x=0; BufferedReader InputStreamReader(System.in)); try { String s= br.readLine(); br=new BufferedReader(new