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

哪里错了,怎么不能运行出来

using System;

using System.Collections.Generic;

using System.Text;


namespace projGetMaxScore

{

    class Program

    {

        static void Main(string[] args)

        {

            string[] scores={89,80,98,56,60,91,93,85};

            string[] names={吴松,钱东宇,伏晨,陈陆,周蕊,林日鹏,何昆,关欣};

            int max=scores[0];

            

            for(int i=0;i<8;i++)

            if(max<scores[i])

            max=scores[i];

            

            {

                Console.WriteLine(最高分数是"+names[i]+",分数是"+max");

            }

        }

    }

}

using System;

using System.Collections.Generic;

using System.Text;


namespace projGetMaxScore

{

    class Program

    {

        static void Main(string[] args)

        {

            string[] scores={89,80,98,56,60,91,93,85};

            string[] names={吴松,钱东宇,伏晨,陈陆,周蕊,林日鹏,何昆,关欣};

            int max=scores[0];

            

            for(int i=0;i<8;i++)

            if(max<scores[i])

            max=scores[i];

            

            {

                Console.WriteLine(最高分数是"+names[i]+",分数是"+max");

            }

        }

    }

}


提问者:慕盖茨9525359 2017-09-26 15:08

个回答

  • qq_清清的风_0
    2017-10-02 15:59:35

    if选择语句里少“{}”大括号


  • WakerL
    2017-09-26 20:03:58

    scores的数组不是整数类型的吗?你用的是string类

    int [] scores={89,80,98,56,60,91,93,85};

                string[] names={"吴松","钱东宇","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};

                int max=scores[0];

                int index = 0;

                for (int  i = 0; i < 8; i++)

                {

                    if (max < scores[i])

                    {

                        max = scores[i];

                        index = i;

      

                    }

                    

                }

                Console.WriteLine("最高分数是" + names[index] + ",分数是" + max);


  • WakerL
    2017-09-26 19:30:34

    你的“最高分数是”你是不是缺了前面的 ”?这里用的是字符串