Skip to content

Instantly share code, notes, and snippets.

@cyberlex404
Created November 17, 2019 14:50
Show Gist options
  • Save cyberlex404/601a65ac00509e63676848786db94593 to your computer and use it in GitHub Desktop.
Save cyberlex404/601a65ac00509e63676848786db94593 to your computer and use it in GitHub Desktop.
interface MaxMass
{
int Max();
int Min();
int SetCount { get; set; }
}
class Mass : MaxMass
{
int Count;
int [] Elem;
public int this[int index]
{
get
{
return Elem[index];
}
set
{
Elem[index] = value;
}
}
public int Max()
{
int result=Elem[0];
for(int i=0;i<Elem.Length;i++)
if (Elem[i]>Elem[result] )
result = i;
return Elem[result];
}
public int Min()
{
int result = Elem[0];
for (int i = 0; i < Elem.Length; i++)
if (Elem[i] < Elem[result])
result = i;
return Elem[result];
}
public int SetCount
{
get
{
return Count;
}
set
{
Elem = new int[value];
Count = value;
}
}
}
class Program
{
static void Main(string[] args)
{
Mass a = new Mass();
a.SetCount = 10;
for (int i = 0; i < a.SetCount; i++)
{
a[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine();
Console.WriteLine(a.Max());
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment