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

这样可行吗???

string[]name=new string{名字}; int[]sorce=new int[]{分数}; int max=0; int i=0; for(int x in sorce) { if(x>=max) { max=x; i++;}}     Console.Write("分数最高为{0}"+name[i]+",分数是{1}"+sorce[i]); 这样可行吗???

正在回答

3 回答

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

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

            int max=sorce[0];

            int y = 0; int x;//x为sorce数组的索引号,y为name数组的所以号

            for(x=0;x<sorce.Length;x++)

            {

              if(sorce[x]>max)

              {

                max=sorce[x];

                y=x;

              }

             }

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

//改成这样就对了,运行过了

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

郭荣俊GG 提问者

非常感谢!
2016-03-28 回复 有任何疑惑可以回复我~

using System;

using System.Collections.Generic;

using System.Text;


namespace projGetMaxScore

{

    class Program

    {

        static void Main(string[] args)

        {

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

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

            int max=score[0];

            string maxname=name[0];

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

            {

                if(max<score[i])

                {

                    max=score[i];

                    maxname=name[i];

                }

            }

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

        }

    }

}


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

 string[]name=new string[]{"吴松","前东宇","伏晨","陈陆","周瑞","林日鹏","何坤","关欣"};
          int[]sorce=new int[]{89,90,98,56,60,91,93,85};
          int max=sorce[0];
          int y=0;
          for(int x=0;x<=sorce.Length;x++)
          {
              if(sorce[x]>max)
              {
              max=sorce[x];
              y=x;
              }
          }
            if( max=sorce[x])
             
          Console.Write("分数最高的是{0}"+",分数是{1}",name[y],max);

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

举报

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

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

进入课程

这样可行吗???

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