91 lines
2.0 KiB
C#
91 lines
2.0 KiB
C#
|
|
using System;
|
||
|
|
namespace Lesson
|
||
|
|
{
|
||
|
|
class Program
|
||
|
|
{
|
||
|
|
static int Compare(int a, int b)
|
||
|
|
{
|
||
|
|
if (a > b)
|
||
|
|
{
|
||
|
|
return a;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
return b;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
static float Compare(float a, float b)
|
||
|
|
{
|
||
|
|
if (a > b)
|
||
|
|
{
|
||
|
|
return a;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
return b;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
static double Compare(double a, double b)
|
||
|
|
{
|
||
|
|
if (a > b)
|
||
|
|
{
|
||
|
|
return a;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
return b;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
static int CompareInf(params int[] a)
|
||
|
|
{
|
||
|
|
int max = 0;
|
||
|
|
for (int i = 0; i < a.Length; i++)
|
||
|
|
{
|
||
|
|
if (a[i] > max)
|
||
|
|
{
|
||
|
|
max = a[i];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return max;
|
||
|
|
}
|
||
|
|
static float CompareInf(params float[] a)
|
||
|
|
{
|
||
|
|
float max = 0.0f;
|
||
|
|
for (int i = 0; i < a.Length; i++)
|
||
|
|
{
|
||
|
|
if (a[i] > max)
|
||
|
|
{
|
||
|
|
max = a[i];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return max;
|
||
|
|
}
|
||
|
|
static double CompareInf(params double[] a)
|
||
|
|
{
|
||
|
|
double max = 0.0d;
|
||
|
|
for (int i = 0; i < a.Length; i++)
|
||
|
|
{
|
||
|
|
if (a[i] > max)
|
||
|
|
{
|
||
|
|
max = a[i];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return max;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
static void Main(string[] args)
|
||
|
|
{
|
||
|
|
Console.WriteLine(Compare(1, 2));
|
||
|
|
Console.WriteLine(Compare(2.1f, 3.2f));
|
||
|
|
Console.WriteLine(Compare(3.675475d, 4.6435432d));
|
||
|
|
|
||
|
|
|
||
|
|
Console.WriteLine(CompareInf(1,2,3,4,5,6,7));
|
||
|
|
Console.WriteLine(CompareInf(1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f));
|
||
|
|
Console.WriteLine(CompareInf(1.1d, 1.2d, 1.3d, 1.4d, 1.5d, 1.6d, 1.7d));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|