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

错在哪呢?

 int[] score = new int[] { 90, 65, 88, 70, 46, 81, 100, 68 };
            string[] name = new string[] { "景珍", "林惠洋", "成蓉", "宏南昌", "龙玉民", "单江开", "田武山", "王三明" };
            int sum = 0, avg, yix;
            for (int i = 0; i < score.Length; i++)
            {
                sum += score[i];
            }
            avg = sum / score.Length;
            Console.Write("平均分是{0},高于平均分的有:", avg);
            Console.WriteLine();
            for (int i = 0; i < name.Length; i++)
            {
                if (score[i] > avg)
                {
                    yix = i;
                    Console.Write(name[i] + " ");
                }
            }
        }

提问者:慕莱坞8957037 2015-11-19 12:22

个回答

  • 暴走男神
    2015-11-26 00:22:14
    已采纳

    第二个for循环不用i 换个其他就可以了

  • li_bera
    2016-01-12 21:41:11

    yix 这个变量没有用到,可以去掉,并且你这个代码没有问题


  • 慕莱坞8957037
    2015-11-27 10:25:25

    好的谢谢