zoukankan      html  css  js  c++  java
  • shiyan7

    package com.cust.wu;

    import java.util.Scanner;
    public class test1 {
    public static void main(String[] args) {

    int[] a= new int[101];
    for(int i=0;i<101;i++){
    a[i]=0;
    }//初始化数组为0
    while (a[0]!=1){
    Scanner scan=new Scanner(System.in);
    System.out.println("输入一个一到100的整数,0结束");

    int num=scan.nextInt();
    if(num>=0&&num<=100){
    a[num]=a[num]+1;
    }
    else{
    System.out.println("输入错误请重新输入");
    }
    }
    System.out.println("输入完毕");
    for(int i=1;i<=100;i++){
    System.out.println("数字"+i+"出现"+a[i]+"次");
    }
    }
    }

    package com.cust.wu;

    import java.util.ArrayList;
    import java.util.Scanner;

    import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

    public class test2 {
    public static void main(String [] args){
    Scanner scan=new Scanner(System.in);
    ArrayList<double[]> list =new ArrayList<double[]>();
    double num=0;
    double sum=0;
    int count=0;
    while(true){
    num=scan.nextDouble();
    if(num<0){
    break;
    }
    else{
    double[] a=new double[1];
    a[0]=num;
    list.add(a);
    sum=sum+num;
    count=count+1;
    }
    }
    double pingjun=sum/count;
    int more=0;
    int less=0;
    for(int i=0;i<list.size();i++){
    double[] a = list.get(i);
    double p = a[0];
    if(p>pingjun){
    more++;
    }
    else{
    less++;
    }

    }
    System.out.println("平均数是"+pingjun+" 高于平均分的个数"+more+" 低于平均分的个数"+less);
    }

    }

  • 相关阅读:
    正则表达式
    移动开发知识点收集
    SQL Server
    百度数据图表插件Echarts
    Xamarin
    Func与Action
    MVC Core
    利用 async & await 的异步编程
    CSS3
    [leetcode]374. Guess Number Higher or Lower
  • 原文地址:https://www.cnblogs.com/helloaworld/p/6037939.html
Copyright © 2011-2022 走看看