问答详情
源自:6-8 最终项目

​5天,还有带回家的C语言,结束啦

5天,还有带回家的C语言,结束啦

http://img2.mukewang.com/5e8f28f500013d0b07960611.jpg

提问者:方方方_ 2020-04-09 21:54

个回答

  • qq_慕侠5280997
    2020-05-10 13:23:39

    using System;
    using System.Collections.Generic;
    using System.Text;
    namespace projAboveAvg
    {
        class Program
        {
            static void Main(string[] args)
            {
                string[,] name = new string[,] { { "景珍", "90" }, { "林慧洋", "65" }, { "成蓉", "88" }, { "洪南昌", "70" }, { "龙玉民", "46" }, { "单江开", "81" }, { "田武山", "100" }, { "王三明", "68" } };
                 int avg,sum=0;
                for (int i = 0; i < name.GetLength(0); i++)
                {
                    sum += int.Parse(name[i, 1]);
                }
                avg = sum / name.GetLength(0);
                Console.WriteLine("平均分是{0},高于平均分的有:", avg);
                for (int i = 0; i < name.GetLength(0); i++)
                {
                    if (avg < int.Parse(name[i, 1]))
                        Console.Write(name[i, 0] + " ");
                }
                Console.ReadKey();
            }
        }
    }

  • 慕哥1330380
    2020-05-08 17:19:30

    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace projAboveAvg
    {
        class Program
        {
            static void Main(string[] args)
            {
                string[] names = new string[] { "景珍", "林惠阳", "成蓉", "洪南昌", "龙玉民", "单江开", "田武山", "王三明", };
                int[] score = new int[] { 90, 65, 83, 70, 56, 81, 100, 68 };
                int avg, sum = 0;
                for (int i = 0; i < score.Length; i++)
                {
                    sum += score[i];
                }
                avg = sum / score.Length;
                Console.Write("平均分是{0},高于平均分的有:", avg);
                Console.ReadKey();
                int s = 76;
                for (int x = 0; x < score.Length; x++)
                {
                    if (score[x] > s)
                    {
                        Console.Write(names[x]+' ');
                    }
                }
            }
        }
    }

    求个最佳答案,嘿嘿。