c#语言。编一个程序,从键盘上输入三个数,把最大数找出来。

控制台的 我是初学者。谢谢了 急急急
2025-03-10 00:33:04
推荐回答(2个)
回答1:

main()
{
consle.writeline("输入三个数");
int a,b,c;
int result;
string str;
str = consle.readline();
a = str.int32.parse();
str = consle.readline();
b = str.int32.parse();
str = consle.readline();
c = str.int32.parse();
result = fun(a,b,c);
}
int fun(int a ,int b,int c)
{
return a>(b>c?b:c)?a:(b>c?b:c);
}
就这么个意思,我电脑没装vs ,consle可能写的不对,你用编辑器的时候会给提示的

回答2:

using System;
 
namespace ConsoleMatrix
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, max = int.MinValue;
            Console.WriteLine("请输入3个数:");
            for (int i = 0; i < 3; i++)
            {
                x = int.Parse(Console.ReadLine());
                if (x > max) max = x;
            }
            Console.WriteLine("最大数为:{0}", max);
        }
    }
}