问答详情
源自:6-1 练习题目

请问为什么这段代码执行不了?

为什么这串代码执行不了?目的是为了挑出最大值。

static void Main(string[] args)
        {
            int N=0;
            int[]score={89,90,98,56,60,91,93,85};
            string[]name={"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};
            for (int i=0;i<score.Length;i++)
            if N<score[i]
            {
                N=i;
            }
            Console.WriteLine("分数最高的是{0},分数是{1}",name[N],score[N]);
        }


提问者:慕神604715 2018-03-30 06:56

个回答

  • qq_RR_15
    2018-05-05 11:09:38

    static void Main(string[] args)
            {
                int[] score={89,90,98,56,60,91,93,85};
                string[] name={"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};

                int N=score[0];//假设第一个分是最高分

                for (int i=1; i<score.Length; i++)

                {
                if (N < score[i])
                {
                    N=score[i];
                }

                }
                Console.WriteLine("分数最高是{0}",N);
            }

    这是求最大值的方法,,这是我的拙见。。。。。

  • 慕神604715
    2018-03-30 06:56:48

    有人么?