zoukankan      html  css  js  c++  java
  • 求平均数,排列顺序为降序

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Collections;
    
    namespace ConsoleApplication2
    {
        class Program
        {
            static void Main(string[] args)
            {
                ArrayList al = new ArrayList();
    
                Console.WriteLine("请输入人数");
                int n =int.Parse(Console.ReadLine());
    
               
                for (int i = 0; i < n; i++)
                {
                    Console.Write("请输入第"+(i+1)+"个学生的分数:");
    
                    al.Add(int.Parse(Console.ReadLine()));
    
               }
                double he = 0;
                    for(int b =0;b<n;b++)
                
                    {
                        he = he + double.Parse(al[b].ToString());
                    }
               
    
                double pj = he  / n;
    
                Console.WriteLine("平均分为"+pj);
    
                al.Sort();
                al.Reverse();
                for (int d = 0; d < n; d++)
                {
                    Console.WriteLine(al[d]);
                }
    
    
    
    
                    Console.ReadLine();
                     
                
                
    
            }
        }
    }
    

      

  • 相关阅读:
    四级英语day9
    123
    像程序员一样思考
    Kali
    OS X
    Effective Java
    DHU ACM OJ
    Ambari
    Hadoop
    Hadoop2
  • 原文地址:https://www.cnblogs.com/suncan0/p/4719496.html
Copyright © 2011-2022 走看看