新手只能写成这样了,不知道怎么用二维数组写?

来源:6-1 练习题目

船丿长

2017-09-28 01:03

static void Main(string[] args)

        {

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

            int [] score ={89,90,98,56,60,91,93,85};

            int maxpeople = 0;

            int maxscore = 0;

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

                if (score[i]>maxscore){

                    maxscore = score[i];

                    maxpeople = i;

                }

            }

            Console.Write("分数最高的是"+names[maxpeople]+",分数是"+score[maxpeople]);

        }


写回答 关注

2回答

  • 慕标1352511
    2017-09-28 17:08:40
    已采纳

    并不能 强类型语言 数组内类型必须一致

    船丿长

    非常感谢!

    2017-09-30 13:49:40

    共 1 条回复 >

  • 慕粉3704942
    2017-12-05 11:54:37

                string[,] test = new string[8, 2] { { "吴松", "89" }, { "钱东宇", "90" }, { "伏晨", "98" }, { "陈璐", "56" }, { "周蕊", "60" }, { "林日鹏", "91" }, { "何坤", "93" }, { "关欣", "85" } };
                int a = 0 , ii = 0;
                string b = "";

                    for (int i = 0; i < test.GetLongLength(0); i++)
                    {
                        if (Convert.ToInt32(test[i, 1]) > a)
                        {
                            //Console.WriteLine(test[i, 1]);
                            a = Convert.ToInt32(test[i, 1]);
                            b = test[i, 0];
                            ii = i;
                        }

                    }
                Console.WriteLine(a);
                Console.WriteLine(b);
                Console.WriteLine(ii);


C#开发轻松入门

本门课程是C#语言的入门教程,将带你轻松入门.NET开发

254118 学习 · 1459 问题

查看课程

相似问题