1 ImportJava.util.Scanner;2 3 4 Public classKongzhitai {5 6 7 Public Static voidMain (string[] args) {8 //TODO Auto-generated method stubs9 Ten //first step output scan received number One intnumber=0;//Defining Variables ASystem.out.println ("Please enter the number of people:"); -Scanner arr=NewScanner (system.in);//Scan -Number=arr.nextint ();//Receive the - //The second step is to assign the received number to the array length . - //Output Scan - Double[] t=New Double[number];//Note the number array length +System.out.println ("Please enter your score:"); -Scanner ar=NewScanner (system.in);//number of scan console inputs + A //The third step is to establish an index that receives input from the number of output arrays and at Doublesum = 0;//Defining Variables - for(inti=0;i<t.length;i++) {//to index the value entered -T[i]=arr.nextdouble ();//Array T[i] receives the scanned data -sum+=T[i]; -}SYSTEM.OUT.PRINTLN ("Total score:" +sum); - in //Fourth Step bubbling Algorithm > [0] is the minimum value <[0] is the maximum value - for(intj=0;j<t.length;j++) {//number of rows to compare to for(inti=0;i<t.length-1-j;i++) {//Number of comparisons (number of columns) + //the more rows you compare, the fewer times you need to compare the number of accompanying numbers, and the less you need to-j the last number so you don't have to compare so-1 - if(t[i]>t[i+1]){ the Doublex=T[i]; *T[i]=t[i+1]; $t[i+1]=x;Panax Notoginseng - } the } +}system.out.println ("The lowest score is:" +t[0]); ASystem.out.println ("Highest score is:" +t[t.length-1]); theSystem.out.println ("Average score is:" +sum/t.length); + } -}
2016/1/10 Example 1, console input number 2, console input corresponding number of results 3, the sum of the results and the maximum minimum value of the average