diff --git a/HomeWork.cs b/HomeWork.cs index ce49999..6e6482c 100644 --- a/HomeWork.cs +++ b/HomeWork.cs @@ -2,6 +2,7 @@ { class HomeWork { + Practics pract = new Practics(); int resaultHW; private int counter; @@ -151,6 +152,54 @@ Console.WriteLine("Array is: " + "[{0}]", string.Join(", ", array)); } + + public int Task_34(int[] array) + { + counter = 0; + for (int i = 0; i < array.Length; i++) + { + if (array[i] % 2 == 0) + counter++; + + } + return counter; + } + + public int Task_36(int[] array) + { + resaultHW = 0; + for (int i = 1; i < array.Length; i++) + { + if (i % 2 != 1) + resaultHW += array[i]; + + } + return resaultHW; + } + + public void Task_38(int[] array) + { + resaultHW = 0; + int maxElement = array[0]; + int minElement = array[0]; + for (int i = 1; i < array.Length; i++) + { + if (maxElement < array[i]) + { + maxElement = array[i]; + } + if (minElement > array[i]) + { + minElement = array[i]; + } + + resaultHW = maxElement - minElement; + + } + Console.WriteLine($"\nDev between max element ({maxElement}) and min ({minElement}) is: {resaultHW}"); + + } + diff --git a/Start.cs b/Start.cs index ccfd6f4..0476438 100644 --- a/Start.cs +++ b/Start.cs @@ -33,6 +33,7 @@ public class Start static void MyTask() { HomeWork HW = new HomeWork(); + Practics pract = new Practics(); Console.Write("Wich task: "); Console.WriteLine("WH2 is 10, 13, 15"); @@ -82,6 +83,32 @@ public class Start Console.WriteLine("Length for array: "); HW.Task_29(ReadIntNumber()); break; + case 34: + Console.WriteLine("Input size mass"); + int size = Convert.ToInt32(Console.ReadLine()); + int min = 100; + int max = 999; + Console.WriteLine("Evan's number is: " + HW.Task_34(pract.newRandomMass(size, min, max))); + break; + case 36: + Console.WriteLine("Input size mass"); + int size1 = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Input min"); + int min1 = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Input max"); + int max1 = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Summ is: " + HW.Task_36(pract.newRandomMass(size1, min1, max1))); + break; + case 38: + Console.WriteLine("Input size mass"); + int size2 = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Input min"); + int min2 = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Input max"); + int max2 = Convert.ToInt32(Console.ReadLine()); + //Console.WriteLine("Summ is: " + HW.Task_38(pract.newRandomMass(size2, min2, max2))); + HW.Task_38(pract.newRandomMass(size2, min2, max2)); + break; default: diff --git a/bin/Debug/net6.0/programming_GB.dll b/bin/Debug/net6.0/programming_GB.dll index 74431eb..4c67568 100644 Binary files a/bin/Debug/net6.0/programming_GB.dll and b/bin/Debug/net6.0/programming_GB.dll differ diff --git a/bin/Debug/net6.0/programming_GB.pdb b/bin/Debug/net6.0/programming_GB.pdb index 3ee28be..cc61297 100644 Binary files a/bin/Debug/net6.0/programming_GB.pdb and b/bin/Debug/net6.0/programming_GB.pdb differ diff --git a/obj/Debug/net6.0/programming_GB.dll b/obj/Debug/net6.0/programming_GB.dll index 74431eb..4c67568 100644 Binary files a/obj/Debug/net6.0/programming_GB.dll and b/obj/Debug/net6.0/programming_GB.dll differ diff --git a/obj/Debug/net6.0/programming_GB.pdb b/obj/Debug/net6.0/programming_GB.pdb index 3ee28be..cc61297 100644 Binary files a/obj/Debug/net6.0/programming_GB.pdb and b/obj/Debug/net6.0/programming_GB.pdb differ diff --git a/obj/Debug/net6.0/ref/programming_GB.dll b/obj/Debug/net6.0/ref/programming_GB.dll index 94714fd..9e11a05 100644 Binary files a/obj/Debug/net6.0/ref/programming_GB.dll and b/obj/Debug/net6.0/ref/programming_GB.dll differ diff --git a/obj/Debug/net6.0/refint/programming_GB.dll b/obj/Debug/net6.0/refint/programming_GB.dll index 94714fd..9e11a05 100644 Binary files a/obj/Debug/net6.0/refint/programming_GB.dll and b/obj/Debug/net6.0/refint/programming_GB.dll differ