麻烦各位

03-05-02 wishton

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