第七次上机作业

package set;

import java.util.Scanner;

public class SKSK {

	public static void main(String[] args) {
		int a[] = new int[10];
        int s = 0, m = 0, min = 1000;
        System.out.println("请输入分数");
        for (int b = 0; b < a.length; b++) {
            Scanner input = new Scanner(System.in);
            a[b] = input.nextInt();
        }
        for (int c = 0; c < a.length; c++) {
            if (a[c] > m) {
                m = a[c];
            }
        }
        for (int x = 0; x < a.length; x++) {
            if (a[x] < min) {
                min = a[x];
            }
        }
        for (int y = 0; y < a.length; y++) {
            s += a[y];
        }
        System.out.println("平均分是" + (s -m-min)/ 8.0);
    }
 
}

  

package set;

import java.util.Random;
import java.util.Scanner;


public class SKSK {

	public static void main(String[] args) {
        int[] b = new int[10];
        Random r=new Random();
        for (int i = 0; i < b.length; i++) {
            b[i]=r.nextInt(100);
        }
        int t;
        for (int i = 0; i < b.length - 1; i++) {
            for (int j = 0; j < b.length-1-i; j++) {
                if (b[j + 1] > b[j]) {
                    t = b[j];
                    b[j] = b[j + 1];
                    b[j + 1] = t;
                }
            }
        }
        for (int i : b) {
            System.out.println(i);
        }

    }
}

  

package set;

import java.util.Random;
import java.util.Scanner;


public class SKSK {
	public static void main(String[] args) {
        // TODO Auto-generated method stub
		  int[] score = new int[7];
	        Random r = new Random();
	        for (int a = 0; a < score.length; a++) {
	            score[a] = r.nextInt(35) + 1;
	        }
	        System.out.println("号码是:");
	        for (int i = 0; i < score.length; i++) {
	            System.out.println(score[i]);
	        }
	    }

	}

  

package set;

import java.util.Random;
import java.util.Scanner;


public class SKSK {
	public static void main(String[] args) {
        // TODO Auto-generated method stub
		  int[]a=new int[]{22,35,44,26,55,72,99,81,31,44};
	        int max=a[0];
	        int	min=a[0];
	        int b=0;
	        int c=0;
	        for(int i=0;i<a.length;i++){
	            if(a[i]>max){
	                max=a[i];
	            }
	            if(a[i]<min){
	                min=a[i];
	            }
	            if(a[i]%2==0){
	                c+=1;
	            }else{
	                b+=1;
	            }
	        }
	        System.out.println("最大值为 "+max);
	        System.out.println("最小值为 "+min);
	        System.out.println("奇数个数为 "+b);
	        System.out.println("偶数个数为 "+c);
	    }
	}

  

posted @ 2020-04-16 13:35  Demens  阅读(98)  评论(0编辑  收藏  举报