写一个Max类,通过方法的重载,可以
(1)计算两个双精度浮点数的最大值;
(2)计算两个整数的最大值;
(3)计算三个整数的最大值。
写main函数,并在函数中正确调用这三个方法
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test
{
class Program
{
class MAX {
public double Max(double a, double b) {
return a > b ? a : b;
}
public int Max(int a, int b) {
return a > b ? a : b;
}
public int Max(int a, int b, int c) {
int max = a;
max = max > b ? max : b;
max = max > c ? max : c;
return max;
}
}
static void Main(string[] args)
{
MAX m = new MAX();
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
Console.WriteLine("max:{0}",m.Max(a,b));
int d = int.Parse(Console.ReadLine());
int e = int.Parse(Console.ReadLine());
int f = int.Parse(Console.ReadLine());
Console.WriteLine("max:{0}", m.Max(d,e,f));
double h = double.Parse(Console.ReadLine());
double i = double.Parse(Console.ReadLine());
Console.WriteLine("max:{0}", m.Max(h,i));
Console.ReadLine();
}
}
}