From 98cf0b96fc5fb81b5bef1dad718ac46bdf368df3 Mon Sep 17 00:00:00 2001 From: weilijiang <3055679233@qq.com> Date: Wed, 14 Apr 2021 20:35:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?java=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Demo02.java" | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 "\346\225\260\347\273\204\347\273\203\344\271\240/\351\237\246\344\270\275\346\261\237/Demo02.java" diff --git "a/\346\225\260\347\273\204\347\273\203\344\271\240/\351\237\246\344\270\275\346\261\237/Demo02.java" "b/\346\225\260\347\273\204\347\273\203\344\271\240/\351\237\246\344\270\275\346\261\237/Demo02.java" new file mode 100644 index 0000000..1688408 --- /dev/null +++ "b/\346\225\260\347\273\204\347\273\203\344\271\240/\351\237\246\344\270\275\346\261\237/Demo02.java" @@ -0,0 +1,61 @@ +package DEMO1; + +import java.util.Scanner; + +public class Demo02 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + // +// - 需求:在编程竞赛中,有6个评委为参赛的选手打分,分数为0-100的整数分。 +// 选手的最后得分为:去掉一个最高分和一个最低分后 的4个评委平均值 (不考虑小数部分)。 +// +//- 思路: +//1.定义一个数组,用动态初始化完成数组元素的初始化,长度为6 +//2.键盘录入评委分数 +//3.由于是6个评委打分,所以,接收评委分数的操作,用循环 +//4.求出数组最大值 +//5.求出数组最小值 +//6.求出数组总和 +//7.按照计算规则进行计算得到平均分 +//8.输出平均分 + + int[] arr ; + arr=new int[6]; + for (int i = 0; i <6; i++) { + + Scanner scanner = new Scanner(System.in); + System.out.println("请输入第"+(i+1)+"评委"); + arr[i]=scanner.nextInt(); + } + + + int max =arr[0]; + int min =arr[0]; + for (int i = 0; i < arr.length; i++) { + + if (maxarr[i]) { + min=arr[i]; + + } + int sum=0; + for (int j = 0; j < arr.length; j++) { + sum=sum+arr[i]; + + } + System.out.println("最大值"+max); + System.out.println("最小值"+min); + System.out.println("总和"+sum); + sum=(sum-max-min)/4; + System.out.println("最后得分是"+sum); + + } + + + } + + } + +} -- Gitee From fad86e9bc8d2a53123d4c6720017b413debc5788 Mon Sep 17 00:00:00 2001 From: weilijiang <3055679233@qq.com> Date: Wed, 14 Apr 2021 21:13:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?java=20=20=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Demo02.java" | 63 +++++++++---------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git "a/\346\225\260\347\273\204\347\273\203\344\271\240/\351\237\246\344\270\275\346\261\237/Demo02.java" "b/\346\225\260\347\273\204\347\273\203\344\271\240/\351\237\246\344\270\275\346\261\237/Demo02.java" index 1688408..26a8300 100644 --- "a/\346\225\260\347\273\204\347\273\203\344\271\240/\351\237\246\344\270\275\346\261\237/Demo02.java" +++ "b/\346\225\260\347\273\204\347\273\203\344\271\240/\351\237\246\344\270\275\346\261\237/Demo02.java" @@ -20,42 +20,37 @@ public class Demo02 { //7.按照计算规则进行计算得到平均分 //8.输出平均分 - int[] arr ; - arr=new int[6]; - for (int i = 0; i <6; i++) { - - Scanner scanner = new Scanner(System.in); - System.out.println("请输入第"+(i+1)+"评委"); - arr[i]=scanner.nextInt(); - } - - - int max =arr[0]; - int min =arr[0]; - for (int i = 0; i < arr.length; i++) { - - if (maxarr[i]) { - min=arr[i]; - - } - int sum=0; - for (int j = 0; j < arr.length; j++) { - sum=sum+arr[i]; - - } - System.out.println("最大值"+max); - System.out.println("最小值"+min); - System.out.println("总和"+sum); - sum=(sum-max-min)/4; - System.out.println("最后得分是"+sum); - } - - } - + System.out.println("最大值为"+max); + min=arr[0]; + for(int i=0;iarr[i]) { + min=arr[i]; + } + } + System.out.println("最小值为:"+min); + for(int i=0;i200) { + System.out.println("请输入正确分数"); + }else { + sum=sum+arr[i]; + } + } + System.out.println("平均分为:"+(sum-max-min)/4); + } - } + + -- Gitee