C#求最大数 [英] C# find biggest number

查看:16
本文介绍了C#求最大数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是第一次使用c#,所以不是很熟悉.如果我让用户输入 3 个数字,我想创建一个简单的程序来查找最大的数字.我只需要知道在代码中放什么,因为我不太确定.

It's the first time I am using c# so I am not very familiar with it. I would like to create a simple program to find the biggest number if I have the user entering 3 numbers. I just need to know what to put in the code, because I am not very sure.

推荐答案

使用Math.Max:

int x = 3, y = 4, z = 5;
Console.WriteLine(Math.Max(Math.Max(x, y), z));

这篇关于C#求最大数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆