Created
November 17, 2019 14:50
-
-
Save cyberlex404/601a65ac00509e63676848786db94593 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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