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

求助!!!这样对吗(在软件可以但是慕课网不可)

string[] ming = new string[] {"景珍","林惠洋","成蓉","洪南昌","龙玉民","单江开","田武山","王三明" };
            int[] fen = new int[]{90,65,88,70,46,81,100,68};
            int pingjun;
            pingjun = (fen[0] + fen[1] + fen[2] + fen[3] + fen[4] + fen[5]  + fen[6] + fen[7])/8;
            Console.WriteLine("平均分是{0},高于平均分的有:", pingjun);
            string  ren;
            for (int i = 0; i < fen.Length; i++)
            {
                if (fen[i] > pingjun)
                {
                    ren = ming[i];
                    Console.Write("{0}"+" ", ren);
                }

            }


提问者:慕标5144039 2019-06-20 18:07

个回答

  • 韩亚强
    2019-06-22 20:03:38

    你这个是对的啊,可以过的,我复制你的都过了。我给稍微改了下,毕竟手东加 太麻烦,不现实,学校有很多学生,一个一个太麻烦!

     string[] ming = new string[] { "景珍", "林惠洋", "成蓉", "洪南昌", "龙玉民", "单江开", "田武山", "王三明" };

                int[] fen = new int[] { 90, 65, 88, 70, 46, 81, 100, 68 };

                int sum = 0,avg;//总分,平均分

                string ren;           

                for (int i = 0; i < fen.Length; i++)

                {

                    sum += fen[i];

                   // Console.WriteLine(sum);//查看总分是否正确

                }

                avg = sum / ming.Length;          

                Console.WriteLine("平均分是{0},高于平均分的有:", avg);

                for (int i = 0; i < fen.Length; i++)

                {

                    if (fen[i] > avg)

                    {

                        ren = ming[i];

                        Console.Write("{0}" + " ", ren);

                    }


                }