为了账号安全,请及时绑定邮箱和手机立即绑定

求救,,,,完全不知道哪里不对,,,

using System;

using System.Collections.Generic;

using System.Text;


namespace projGetMaxScore

{

    class Program

    {

        static void Main(string[] args)

        {

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

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

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

            {

                int max = 0;

                if (max < score[i])

                {

                    max = score[i];

                }

                Console.Write("分数最高的是{0},分数是{1}", name[i], max);

            }   

        }

    }

}


正在回答

2 回答

//你的new数组语法错了,然后max这个变量要全局变量,输出语句也放错地方了这个是我修改你代码之后的。你可以看看。

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

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

        int max = 0;

        string topname=null;

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

                if (max < score[i]){                  

                    max = score[i];

                    topname=name[i];

                }

                

            }  

            Console.Write("分数最高的是{0},分数是{1}", topname, max);


2 回复 有任何疑惑可以回复我~
#1

weixin_慕少4095589 提问者

太感谢啦!!!
2018-11-30 回复 有任何疑惑可以回复我~

太感谢啦!!!

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
C#开发轻松入门
  • 参与学习       251738    人
  • 解答问题       1448    个

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

进入课程

求救,,,,完全不知道哪里不对,,,

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信