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

运行成功 输出错误

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

提问者:IT通行证 2019-05-04 12:30

个回答

  • 墨铭亓邈
    2019-05-17 16:55:52

    运行结果意思是对的,结果有误是你的标点格式与答案不一样,你换成中文逗号就可以了

  • 慕码人3565934
    2019-05-14 11:21:03

    是对的,没问题

  • 慕码人3565934
    2019-05-14 11:18:35

    string[,] test = new string[8, 2] { { "吴松", "89" }, { "钱东宇", "90" }, { "伏晨", "98" }, { "陈陆", "56" }, { "周蕊", "60" }, { "林日鹏", "91" }, { "何昆", "93" }, { "关欣", "85" } };
            int max = 0, m = 0;
            for (int i = 0; i < test.GetLongLength(0); i++)
            {
                int n = Convert.ToInt16(test[i, 1]);
                if (n >= max)
                {
                    max = n;
                    m = i;
                }
            }
            Console.WriteLine("分数最高的是{0},分数是{1}。", test[m, 0], test[m, 1]);