麻烦各位

03-05-02 wishton


 <BR>import java.util.*; <BR>import javax.swing.*; <BR><BR>public class LotteryDrawing <BR>{ <BR>public static void main(String[] args) <BR>{ <BR>String input= JOptionPane.showInputDialog <BR>("How many number do you need to draw?"); <BR>int k=Integer.parseInt(input); //把一个整数字符串转换成 int <BR><BR>input=JOptionPane.showInputDialog <BR>("What is the highest number you can draw?"); <BR><BR>int n=Integer.parseInt(input); <BR><BR>int[] number=new int [n]; <BR><BR>for(int i=0;i<number.length;i++) <BR>number[i]=i+1; //是把 i+1 的值赋给 数组元素吗? <BR><BR>int[] result=new int[k]; <BR><BR>for(int i=0;i<result.length;i++)//从这里开始 <BR>{ <BR>int r=(int)(Math.random()*n); <BR><BR>result[i]=number[r]; <BR>number[r]=number[n-1]; <BR>n--; <BR>} //到这里 在做什么 <BR><BR>Arrays.sort(result);//对result排序 <BR>System.out.println("Bet the following combination. It'll make you rich!"); <BR><BR>for(int i=0;i<result.length;i++) <BR>System.out.println(result[i]); <BR>System.exit(0);//这里的退出必须要写吗?为什么,当上面那个for循环为假 就应该自动退出? <BR>} <BR>} <BR><BR>问提在注释里,