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

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

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]);

        }


提问者:船丿长 2017-09-28 01:03

个回答

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

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

  • 慕粉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);