问答详情
源自:2-19 C#的逻辑运算符(二)

2-19

最后任务

提问者:慕沐1208226 2017-05-19 15:39

个回答

  • 来来lan
    2017-05-19 19:54:19

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