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

可以了。。。

using System;


class Program

{

    static void Main(string[] args)

    {

        // 创建一个学生姓名和分数的字典

        var scores = new System.Collections.Generic.Dictionary<string, int>();


        // 添加学生信息和分数

        scores.Add("吴松", 89);

        scores.Add("钱东宇", 90);

        scores.Add("伏晨", 98);

        scores.Add("陈陆", 56);

        scores.Add("周蕊", 60);

        scores.Add("林日鹏", 91);

        scores.Add("何昆", 93);

        scores.Add("关欣", 85);


        // 初始化最高分为0

        int maxScore = 0;

        string topStudent = "";


        // 遍历字典,找到分数最高的学生

        foreach (var student in scores)

        {

            if (student.Value > maxScore)

            {

                maxScore = student.Value;

                topStudent = student.Key;

            }

        }


        // 输出分数最高的学生姓名和分数

        Console.WriteLine("分数最高的是:" + topStudent);

        Console.WriteLine("分数是:" + maxScore);


    }

}


正在回答

举报

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

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

进入课程

可以了。。。

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