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

测出的结果

using System;

using System.Collections.Generic;

using System.Text;


namespacehttps://www.imooc.com/code/9177#editor-tabs-csharp projGetMaxScore

{

    class Program

    {

        static void Main(string[] args)

        {

            int i; int t=0;

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

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

            for(i=0;i<score.Length;i++)

            {

                if(score[i]>score[t])

                t=i;

            }

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

        }

    }

}


正在回答

1 回答

string[] name=new string[] {"景珍","林惠洋","成蓉","洪南昌","龙玉民","单江开","田武山","王三明"};

           int [] score=new int[] {90,65,88,70,46,81,100,68};

           int sum=0,avg;

           for(int i=0;i<score.Length;i++){

               sum+=score[i];

           }

           avg=sum/score.Length;

           Console.WriteLine("平均分是{0},高于平均分的有:",avg);

           for(int i=0;i<score.Length;i++){

               if(score[i]>avg){

                   Console.Write(name[i]+" ");

               }

           }

这题第一个循环先求和,然后算出平均数,第二个循环将每个人的分数与平均数比较,若大于平均数,则输出姓名加空格 ,比如     name+" "

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

举报

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

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

进入课程

测出的结果

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