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

我哪里有问题啊 我在vs上面都没问题 在这里就不行

using System;

using System.Collections.Generic;

using System.Text;


namespace projGetMaxScore

{

    class Program

    {

        static void Main(string[] args)

        {

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

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

            int max;

            max = a[0];

            int sy = 0;

            for(int i=1;i<a.Length;i++)

            {

                if (a[i] > max)

                {

                    max = a[i];

                    sy = i;

                }

            }

            Console.Write("分数最高的是" +name[sy]+","+"分数是"+max);

            

        }

    }

}


正在回答

5 回答

using System;

using System.Collections.Generic;

using System.Text;


namespace projGetMaxScore

{

    class Program

    {

        static void Main(string[] args)

        {

            int max;

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

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

            max=num[0];

            string k =name[0];

            for(int i=1;i<num.Length;i++)

            {

                if(num[i]>max)

                {

                    max=num[i];

                    k=name[i];

                    

                }

            }

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

        }

    }

}


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

?,看来不是我一个人是这个思路,?

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

你的代码没错,不对是因为名字和分数之间的,是中文的,你的是英文?

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

没有伞的前行者

大佬你学习C#多久了呀
2020-03-27 回复 有任何疑惑可以回复我~

using System;

using System.Collections.Generic;

using System.Text;


namespace projGetMaxScore

{

    class Program

    {

        static void Main(string[] args)

        {

            string[,] chengji=new string[,]{

                {"吴松","89"},{"钱东宇","90"},

                {"伏晨","98"},{"陈陆","56"},

                {"周蕊","60"},{"林日鹏","91"},

                {"何昆","93"},{"关欣","85"}

            };

            string[] zuigao=new string[2];

            for(int x=0; x<chengji.GetLongLength(0);x++){

                if(zuigao[0]!=null && Convert.ToInt32(zuigao[1])>Convert.ToInt32(chengji[x,1])) continue;

                else{

                    zuigao[0]=chengji[x,0];

                    zuigao[1]=chengji[x,1];

                }

            }

            Console.WriteLine("分数最高的是{0},分数是{1}",zuigao[0],zuigao[1]);

        }

    }

}

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

代码确实没问题,我写的也对就是在这上面不对,你的i从0开始比较规范,改一改

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

举报

0/150
提交
取消

我哪里有问题啊 我在vs上面都没问题 在这里就不行

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