深圳网站设计收费标准,html购物网站源码,北京今天最新新闻,济南市做网站公司1、 考试成绩已保存在数组 scores中#xff0c;数组元素依次为 89 , -23 , 64 , 91 , 119 , 52 , 732、 要求通过自定义方法来实现成绩排名并输出操作#xff0c;将成绩数组作为参数传入3、 要求判断成绩的有效性#xff08; 0—100 #xff09;#xff0c;如果成绩无效数组元素依次为 89 , -23 , 64 , 91 , 119 , 52 , 732、 要求通过自定义方法来实现成绩排名并输出操作将成绩数组作为参数传入3、 要求判断成绩的有效性 0—100 如果成绩无效则忽略此成绩 /* 小伙伴们请根据所学知识编写一个 JAVA 程序实现输出考试成绩的前三名 要求 1、 考试成绩已保存在数组 scores中数组元素依次为 89 , -23 , 64 , 91 , 119 , 52 , 73 2、 要求通过自定义方法来实现成绩排名并输出操作将成绩数组作为参数传入 3、 要求判断成绩的有效性 0—100 如果成绩无效则忽略此成绩 */package lianxi;
import java.util.*;
public class HelloWorld {public static void main(String[] args) {int[] scores{89,-23,64,91,119,52,73}; //创建一个数组System.out.println(考试成绩的前三名为);HelloWorld Fgradenew HelloWorld(); //创建一个对象Fgrade.grade(scores);//调用方法}public void grade(int[] scores){Arrays.sort(scores); //对数组进行升序排序int count1;for(int iscores.length-1;i0count3;i--){if(scores[i]100||scores[i]0) continue;else {count;System.out.println(scores[i]);}}}
} 操作结果 考试成绩的前三名为
91
89
73 转载于:https://www.cnblogs.com/spsglz/p/7773052.html