packagecom.Jsucs;//在数列中查找一个数,如果找到了就返回一个ture,否则就返回一个falsepublicclassUseway{publicstaticvoidmain(String[] args){int[] arr ={12,23,34,45,56,67,78,89,90};System.out.println(arry( arr,34));}publicstaticbooleanarry(int[] arr,int num){for(int i =0; i < arr.length; i++){if( arr[i]== num){returntrue;}}returnfalse;}}
packagecom.Jsucs;importjava.util.Scanner;publicclass useway03 {publicstaticvoidmain(String[] args){int[] socerArr =getSocres();for(int i =0; i < socerArr.length; i++){System.out.println(socerArr[i]);}int max =getMax(socerArr);int min =getMin(socerArr);int sum =getSum(socerArr);int avg =(sum - max -min)/(socerArr.length-2);System.out.println(avg);}publicstaticintgetMax(int[] scoreArr){int max = scoreArr[0];for(int i =0; i < scoreArr.length; i++){if(scoreArr[i]< max){
max = scoreArr[i];}}return max;}publicstaticintgetMin(int[] scoreArr){int min = scoreArr[0];for(int i =0; i < scoreArr.length; i++){if(scoreArr[i]< min){
min = scoreArr[i];}}return min;}publicstaticintgetSum(int[] scoreArr){int sum =0;for(int i =0; i < scoreArr.length; i++){
sum = sum +scoreArr[i];}return sum;}publicstaticint[]getSocres(){int[] scores =newint[6];Scanner sc =newScanner(System.in);for(int i =0; i < scores.length;){System.out.println("请输入评委打分");int score= sc.nextInt();if(score >=0&& score <=100){
scores[i]= score;
i++;}else{System.out.println("成绩超出范围,当前i为:"+ i);}}return scores;}}