diff --git a/BubbleSort/BubbleSort.sln b/BubbleSort/BubbleSort.sln
new file mode 100644
index 0000000..df51044
--- /dev/null
+++ b/BubbleSort/BubbleSort.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.32112.339
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BubbleSort", "BubbleSort\BubbleSort.csproj", "{BAEBC175-D9F7-4975-8B11-7E2C70359D0D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {BAEBC175-D9F7-4975-8B11-7E2C70359D0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BAEBC175-D9F7-4975-8B11-7E2C70359D0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BAEBC175-D9F7-4975-8B11-7E2C70359D0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BAEBC175-D9F7-4975-8B11-7E2C70359D0D}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {DCF0EF43-DBBE-4FAF-8C6E-8E0DACF185D7}
+ EndGlobalSection
+EndGlobal
diff --git a/BubbleSort/BubbleSort/BubbleSort.csproj b/BubbleSort/BubbleSort/BubbleSort.csproj
new file mode 100644
index 0000000..74abf5c
--- /dev/null
+++ b/BubbleSort/BubbleSort/BubbleSort.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/BubbleSort/BubbleSort/Program.cs b/BubbleSort/BubbleSort/Program.cs
new file mode 100644
index 0000000..3751555
--- /dev/null
+++ b/BubbleSort/BubbleSort/Program.cs
@@ -0,0 +1,2 @@
+// See https://aka.ms/new-console-template for more information
+Console.WriteLine("Hello, World!");
diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj
index ae46394..14672dc 100644
--- a/CourseApp.Tests/CourseApp.Tests.csproj
+++ b/CourseApp.Tests/CourseApp.Tests.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.1
+ netcoreapp6.0
True
1573,1591,1701;1702;1705
false
diff --git a/CourseApp.Tests/Module2/BubbleSortTest.cs b/CourseApp.Tests/Module2/BubbleSortTest.cs
index 8a9b192..445670f 100644
--- a/CourseApp.Tests/Module2/BubbleSortTest.cs
+++ b/CourseApp.Tests/Module2/BubbleSortTest.cs
@@ -8,11 +8,15 @@ namespace CourseApp.Tests.Module2
[Collection("Sequential")]
public class BubbleSortTest : IDisposable
{
- private const string Inp1 = @"7
-5 1 7 3 9 4 1";
+ private const string Inp1 = @"4
+4 3 2 1";
- private const string Inp2 = @"3
--10 7 2";
+ private const string Out1 = @"3 4 2 1
+3 2 4 1
+3 2 1 4
+2 3 1 4
+2 1 3 4
+1 2 3 4";
public void Dispose()
{
@@ -24,8 +28,8 @@ public void Dispose()
}
[Theory]
- [InlineData(Inp1, "1 1 3 4 5 7 9")]
- [InlineData(Inp2, "-10 2 7")]
+ [InlineData(Inp1, Out1)]
+
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
@@ -39,7 +43,9 @@ public void Test1(string input, string expected)
// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
- Assert.Equal($"{expected}", output[0]);
+ var res = string.Join(Environment.NewLine, output);
+
+ Assert.Equal($"{expected}", res);
}
}
}
diff --git a/CourseApp.Tests/Module2/CountInversionsTest.cs b/CourseApp.Tests/Module2/CountInversionsTest.cs
new file mode 100644
index 0000000..eae02f6
--- /dev/null
+++ b/CourseApp.Tests/Module2/CountInversionsTest.cs
@@ -0,0 +1,58 @@
+using System;
+using System.IO;
+using CourseApp.Module2;
+using Xunit;
+
+namespace CourseApp.Tests.Module2
+{
+ [Collection("Sequential")]
+ public class CountInversionsTest : IDisposable
+ {
+ private const string Inp1 = @"1
+1";
+
+ private const string Out1 = @"0";
+
+ private const string Inp2 = @"2
+3 1";
+
+ private const string Out2 = @"1";
+
+ private const string Inp3 = @"5
+5 4 3 2 1";
+
+ private const string Out3 = @"10";
+
+ public void Dispose()
+ {
+ var standardOut = new StreamWriter(Console.OpenStandardOutput());
+ standardOut.AutoFlush = true;
+ var standardIn = new StreamReader(Console.OpenStandardInput());
+ Console.SetOut(standardOut);
+ Console.SetIn(standardIn);
+ }
+
+ [Theory]
+ [InlineData(Inp1, Out1)]
+ [InlineData(Inp2, Out2)]
+ [InlineData(Inp3, Out3)]
+
+ public void Test1(string input, string expected)
+ {
+ var stringWriter = new StringWriter();
+ Console.SetOut(stringWriter);
+
+ var stringReader = new StringReader(input);
+ Console.SetIn(stringReader);
+
+ // act
+ CountInversions.CountInversionsMethod();
+
+ // assert
+ var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
+ var result = string.Join(Environment.NewLine, output);
+
+ Assert.Equal($"{expected}", result);
+ }
+ }
+}
diff --git a/CourseApp.Tests/Module2/MergeSortTest.cs b/CourseApp.Tests/Module2/MergeSortTest.cs
new file mode 100644
index 0000000..8984107
--- /dev/null
+++ b/CourseApp.Tests/Module2/MergeSortTest.cs
@@ -0,0 +1,57 @@
+using System;
+using System.IO;
+using Xunit;
+using CourseApp.Module2;
+
+namespace CourseApp.Tests.Module2
+{
+ [Collection("Sequential")]
+ public class MergeSortTest : IDisposable
+ {
+ private const string Inp1 = @"2
+3 1";
+
+ private const string Out1 = @"1 2 1 3
+1 3 ";
+
+ private const string Inp2 = @"5
+5 4 3 2 1";
+
+ private const string Out2 = @"1 2 4 5
+4 5 1 2
+3 5 1 3
+1 5 1 5
+1 2 3 4 5 ";
+
+ public void Dispose()
+ {
+ var standardOut = new StreamWriter(Console.OpenStandardOutput());
+ standardOut.AutoFlush = true;
+ var standardIn = new StreamReader(Console.OpenStandardInput());
+ Console.SetOut(standardOut);
+ Console.SetIn(standardIn);
+ }
+
+ [Theory]
+ [InlineData(Inp1, Out1)]
+ [InlineData(Inp2, Out2)]
+
+ public void Test1(string input, string expected)
+ {
+ var stringWriter = new StringWriter();
+ Console.SetOut(stringWriter);
+
+ var stringReader = new StringReader(input);
+ Console.SetIn(stringReader);
+
+ // act
+ MergeSort.MergeSortMethod();
+
+ // assert
+ var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
+ var res = string.Join(Environment.NewLine, output);
+
+ Assert.Equal($"{expected}", res);
+ }
+ }
+}
diff --git a/CourseApp.Tests/Module2/PairSortTest.cs b/CourseApp.Tests/Module2/PairSortTest.cs
new file mode 100644
index 0000000..a3a6d54
--- /dev/null
+++ b/CourseApp.Tests/Module2/PairSortTest.cs
@@ -0,0 +1,49 @@
+using System;
+using System.IO;
+using Xunit;
+using CourseApp.Module2;
+
+namespace CourseApp.Tests.Module2
+{
+ [Collection("Sequential")]
+ public class PairSortTest : IDisposable
+ {
+ private const string Inp1 = @"3
+20 80
+30 90
+25 90";
+
+ private const string Out1 = @"25 90
+30 90
+20 80";
+
+ public void Dispose()
+ {
+ var standardOut = new StreamWriter(Console.OpenStandardOutput());
+ standardOut.AutoFlush = true;
+ var standardIn = new StreamReader(Console.OpenStandardInput());
+ Console.SetOut(standardOut);
+ Console.SetIn(standardIn);
+ }
+
+ [Theory]
+ [InlineData(Inp1, Out1)]
+ public void Test1(string input, string expected)
+ {
+ var stringWriter = new StringWriter();
+ Console.SetOut(stringWriter);
+
+ var stringReader = new StringReader(input);
+ Console.SetIn(stringReader);
+
+ // act
+ PairSort.PairSortMethod();
+
+ // assert
+ var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
+ var res = string.Join(Environment.NewLine, output);
+
+ Assert.Equal($"{expected}", res);
+ }
+ }
+}
diff --git a/CourseApp.Tests/Module2/WarehouseTest.cs b/CourseApp.Tests/Module2/WarehouseTest.cs
new file mode 100644
index 0000000..e7be17d
--- /dev/null
+++ b/CourseApp.Tests/Module2/WarehouseTest.cs
@@ -0,0 +1,52 @@
+using System;
+using System.IO;
+using Xunit;
+using CourseApp.Module2;
+
+namespace CourseApp.Tests.Module2
+{
+ [Collection("Sequential")]
+ public class WarehouseTest : IDisposable
+ {
+ private const string Inp1 = @"5
+1 50 3 4 3
+16
+1 2 3 4 5 1 3 3 4 5 5 5 5 5 4 5";
+
+ private const string Out1 = @"yes
+no
+no
+no
+yes";
+
+ public void Dispose()
+ {
+ var standardOut = new StreamWriter(Console.OpenStandardOutput());
+ standardOut.AutoFlush = true;
+ var standardIn = new StreamReader(Console.OpenStandardInput());
+ Console.SetOut(standardOut);
+ Console.SetIn(standardIn);
+ }
+
+ [Theory]
+ [InlineData(Inp1, Out1)]
+
+ public void Test1(string input, string expected)
+ {
+ var stringWriter = new StringWriter();
+ Console.SetOut(stringWriter);
+
+ var stringReader = new StringReader(input);
+ Console.SetIn(stringReader);
+
+ // act
+ Warehouse.WarehouseMethod();
+
+ // assert
+ var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
+ var res = string.Join(Environment.NewLine, output);
+
+ Assert.Equal($"{expected}", res);
+ }
+ }
+}
diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj
index 9551450..270a411 100644
--- a/CourseApp/CourseApp.csproj
+++ b/CourseApp/CourseApp.csproj
@@ -2,7 +2,7 @@
Exe
- netcoreapp2.1
+ netcoreapp6.0
True
1573,1591,1701;1702;1705;
diff --git a/CourseApp/Module2/BubbleSort.cs b/CourseApp/Module2/BubbleSort.cs
index cc49214..0dfef9b 100644
--- a/CourseApp/Module2/BubbleSort.cs
+++ b/CourseApp/Module2/BubbleSort.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace CourseApp.Module2
{
@@ -8,31 +6,39 @@ public class BubbleSort
{
public static void BubbleSortMethod()
{
- int n = int.Parse(Console.ReadLine());
- string s = Console.ReadLine();
- string[] sValues = s.Split(' ');
- int[] arr = new int[n];
- for (int i = 0; i < n; i++)
+ int number = int.Parse(Console.ReadLine()); // int.Parse - Преобразует строковое представление числа в указанном формате в эквивалентное ему 32-битовое целое число со знаком.
+ string str = Console.ReadLine(); // содали строку для ввода элментов, считываем
+ string[] sValues = str.Split(' '); // массив строк для разделения элементов через пробел. sValues - Строковое представление элемента
+ int[] array = new int[number]; // содали массив размерностью, которую указали ранее в number
+ for (int i = 0; i < number; i++)
{
- arr[i] = int.Parse(sValues[i]);
+ array[i] = int.Parse(sValues[i]); // перебор от первого до последнего элемента, преобразование каждого строкогого элемента в число с записью в массив
}
- for (int i = 0; i < arr.Length - 1; i++)
+ bool flag = false;
+
+ for (int i = 0; i < array.Length - 1; i++)
{
- for (int j = 0; j < arr.Length - i - 1; j++)
+ for (int j = 0; j < array.Length - i - 1; j++)
{
- if (arr[j] > arr[j + 1])
+ if (array[j] > array[j + 1])
{
- // int temp = arr[j];
- // arr[j] = arr[j + 1];
- // arr[j+1] = temp;
- (arr[j], arr[j + 1]) = (arr[j + 1], arr[j]);
+ (array[j], array[j + 1]) = (array[j + 1], array[j]); // сравниваем предыдущий элемент (i) с последующим (j), если элемент массива i больше элемента массива j, то меняем элементы местами
+ string result = string.Join(" ", array);
+ Console.WriteLine(result);
+ flag = true;
}
}
}
- string result = string.Join(" ", arr);
- Console.WriteLine(result);
+ if (flag == false)
+ {
+ Console.WriteLine(0);
+ }
+ else
+ {
+ flag = false;
+ }
}
}
}
diff --git a/CourseApp/Module2/CountInversions.cs b/CourseApp/Module2/CountInversions.cs
new file mode 100644
index 0000000..295af3a
--- /dev/null
+++ b/CourseApp/Module2/CountInversions.cs
@@ -0,0 +1,89 @@
+using System;
+
+namespace CourseApp.Module2
+{
+ public class CountInversions
+ {
+ private static long inversionsCount;
+
+ public static void CountInversionsMethod()
+ {
+ MergeSortClone(); // Подсмотрела у Ваньки из 42 как это запустить нормально
+ }
+
+ public static void MergeSortClone()
+ {
+ inversionsCount = 0; // счётчик инверсий
+ int num = int.Parse(Console.ReadLine()); // Запись кол-ва элементов в массиве, преобразовывая строковое значение в 32-битовое целое число со знаком
+
+ if (num >= 1)
+ {
+ string str = Console.ReadLine(); // содали строку для ввода элментов, считываем
+ string[] sValues = str.Split(' '); // массив строк для разделения элементов через пробел. sValues - Строковое представление элемента
+ int[] array = new int[num];
+
+ for (int i = 0; i < sValues.Length; i++)
+ {
+ array[i] = int.Parse(sValues[i]); // перебор от первого до последнего элемента, преобразование каждого строкогого элемента в число с записью в массив
+ }
+
+ int[] result = Sorting(array, 0, num);
+ Console.WriteLine($"{inversionsCount}"); // вывод кол-ва инверсий
+ }
+ else
+ {
+ Console.WriteLine(0); // если перестановок нет, вывести 0
+ }
+ }
+
+ public static int[] MergeSort(int[] left, int[] right)
+ {
+ int i = 0; // индекс для left
+ int j = 0; // индекс для right
+ // код из MergeSort
+ int[] result = new int[left.Length + right.Length]; // в результате слияние двух длин левой и правой частей
+ for (int k = 0; k < result.Length; k++)
+ {
+ if (i == left.Length)
+ {
+ result[k] = right[j];
+ j++;
+ }
+ else if (j == right.Length)
+ {
+ result[k] = left[i];
+ i++;
+ }
+ else if (left[i] <= right[j])
+ {
+ result[k] = left[i];
+ i++;
+ }
+ else
+ {
+ result[k] = right[j];
+ j++;
+ inversionsCount += left.Length - i;
+ }
+ }
+
+ return result;
+ }
+
+ public static int[] Sorting(int[] mas, int lowIndex, int highIndex)
+ {
+ if (highIndex - lowIndex == 1)
+ {
+ int[] res = new int[1];
+ res[0] = mas[lowIndex];
+ return res;
+ }
+
+ int middleIndex = (lowIndex + highIndex) / 2; // "средний" индекс будет равен раздёленной пополам сумме первого и последнего
+ int[] left = Sorting(mas, lowIndex, middleIndex); // левая часть будет отсортирована из массива от первого до "среднего" индекса
+ int[] right = Sorting(mas, middleIndex, highIndex); // правая часть будет отсортирована из массива от "среднего" до последнего индекса
+
+ return MergeSort(left, right);
+ }
+ }
+}
diff --git a/CourseApp/Module2/MergeSort.cs b/CourseApp/Module2/MergeSort.cs
new file mode 100644
index 0000000..d375964
--- /dev/null
+++ b/CourseApp/Module2/MergeSort.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Text;
+
+namespace CourseApp.Module2
+{
+ public class MergeSort
+ {
+ public static void MergeSortMethod() // ввод:
+ {
+ int num = int.Parse(Console.ReadLine()); // int.Parse - Преобразует строковое представление числа в указанном формате в эквивалентное ему 32-битовое целое число со знаком.
+ string str = Console.ReadLine(); // содали строку для ввода элментов, считываем
+ string[] sValues = str.Split(' '); // массив строк для разделения элементов через пробел. sValues - Строковое представление элемента
+ int[] array = new int[num]; // содали массив размерностью, которую указали ранее в num
+ for (int i = 0; i < num; i++)
+ {
+ array[i] = int.Parse(sValues[i]); // перебор от первого до последнего элемента, преобразование каждого строк.элемента в число с записью в массив
+ }
+
+ int[] result = MergeSorting(array, 0, num); // вызываем merge sort и задаём туда массив, нулевой индекс 0 и последний индекс = значению num
+ for (int i = 0; i < result.Length; i++)
+ {
+ Console.Write($"{result[i]} ");
+ }
+ }
+
+ public static int[] Merge(int[] left, int[] right)
+ {
+ int i = 0; // индекс для left
+ int j = 0; // индекс для right
+ int[] result = new int[left.Length + right.Length]; // в результате слияние двух длин левой и правой частей
+ for (int k = 0; k < result.Length; k++)
+ {
+ if (i == left.Length)
+ {
+ result[k] = right[j];
+ j++;
+ }
+ else if (j == right.Length)
+ {
+ result[k] = left[i];
+ i++;
+ }
+ else if (left[i] <= right[j])
+ {
+ result[k] = left[i];
+ i++;
+ }
+ else
+ {
+ result[k] = right[j];
+ j++;
+ }
+ }
+
+ return result;
+ }
+
+ public static int[] MergeSorting(int[] mas, int lowIndex, int highIndex)
+ {
+ if (highIndex - lowIndex == 1)
+ {
+ int[] res = new int[1]; // если размерность (разность последнего и первого индексов) массива равна единице, выведем сам элемент массива
+ res[0] = mas[lowIndex];
+ return res;
+ }
+
+ int middleIndex = (lowIndex + highIndex) / 2; // "средний" индекс будет равен раздёленной пополам сумме первого и последнего
+ int[] left = MergeSorting(mas, lowIndex, middleIndex); // левая часть будет отсортирована из массива от первого до "среднего" индекса
+ int[] right = MergeSorting(mas, middleIndex, highIndex); // правая часть будет отсортирована из массива от "среднего" до последнего индекса
+ int[] result = Merge(left, right); // в результате запишем слияние левой и правой частей после merge
+ Console.WriteLine($"{lowIndex + 1} {highIndex} {result[0]} {result[^1]}"); // вывод нулевого (первого, поэтому +1) индекса из области слияния, идекс конца области, значение нулевого (первого) элемента и посленего элемента области
+
+ return Merge(left, right);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/Module2/PairSort.cs b/CourseApp/Module2/PairSort.cs
new file mode 100644
index 0000000..8959c3a
--- /dev/null
+++ b/CourseApp/Module2/PairSort.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Text;
+
+namespace CourseApp.Module2
+{
+ public class PairSort
+ {
+ public static void PairSortMethod()
+ {
+ int amountPair = int.Parse(Console.ReadLine()); // считываем ожидаемое количество пар
+ int[,] pairs = new int[amountPair, 2]; // Заводим массив, в который запишем каждую пару. Раздление по 2 элемента в паре
+ for (int i = 0; i < amountPair; i++)
+ {
+ var readPair = Console.ReadLine().Split(" "); // считывание элементов пар через пробел
+ pairs[i, 0] = int.Parse(readPair[0]); // преобразование к числу первого (нулевого) элемента
+ pairs[i, 1] = int.Parse(readPair[1]); // проебразование к числу второго (первого) элемента
+ }
+
+ for (int i = 0; i < (pairs.Length / 2) - 1; i++)
+ {
+ for (int j = 0; j < (pairs.Length / 2) - i - 1; j++)
+ {
+ if (pairs[j, 1] < pairs[j + 1, 1])
+ {
+ (pairs[j, 0], pairs[j + 1, 0]) = (pairs[j + 1, 0], pairs[j, 0]); // сравнение первых (нулевых) элементов из соседних пар, сортировка их по убыванию
+ (pairs[j, 1], pairs[j + 1, 1]) = (pairs[j + 1, 1], pairs[j, 1]); // сравнение вторых (первых) элементов из соседних пар, сортировка по убыванию
+ }
+ else if (pairs[j, 1] == pairs[j + 1, 1])
+ {
+ if (pairs[j, 0] > pairs[j + 1, 0])
+ {
+ (pairs[j, 0], pairs[j + 1, 0]) = (pairs[j + 1, 0], pairs[j, 0]);
+ (pairs[j, 1], pairs[j + 1, 1]) = (pairs[j + 1, 1], pairs[j, 1]);
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < pairs.Length / 2; i++)
+ {
+ Console.WriteLine($"{pairs[i, 0]} {pairs[i, 1]}"); // вывод
+ }
+ }
+ }
+}
diff --git a/CourseApp/Module2/Warehouse.cs b/CourseApp/Module2/Warehouse.cs
new file mode 100644
index 0000000..dafa80f
--- /dev/null
+++ b/CourseApp/Module2/Warehouse.cs
@@ -0,0 +1,73 @@
+using System;
+
+namespace CourseApp.Module2
+{
+ public class Warehouse
+ {
+ public static void CountInversionsMethod()
+ {
+ WarehouseMethod();
+ }
+
+ public static void WarehouseMethod()
+ {
+ int numberProd = int.Parse(Console.ReadLine()); // считываем количество видов товара на складе
+ int[] prod = new int[numberProd]; // создали массив под колчичество видов товара на складе
+ string valuesProd = Console.ReadLine(); // содали строку для ввода элментов, считываем количество товаров i-го вида на складе.
+ string[] sValuesProd = valuesProd.Split(' '); // массив строк для разделения элементов через пробел. sValues - Строковое представление элемента
+
+ for (int i = 0; i < numberProd; i++)
+ {
+ prod[i] = int.Parse(sValuesProd[i]); // перебор от первого до последнего элемента, преобразование каждого строкогого элемента в число с записью в массив
+ }
+
+ int numberOrd = int.Parse(Console.ReadLine()); // считываем общее количество заказов клиентов
+ string valuesOrd = Console.ReadLine(); // создали строку для ввода элментов, считываем заказы клиентов в произвольном порядке.
+ string[] sValuesOrd = valuesOrd.Split(' '); // массив строк для разделения элементов через пробел. sValues - Строковое представление элемента
+ int[] ord = new int[numberOrd]; // массив под заказы клиентов заполняем данными из numberOrd
+ int max = 0; // берём точку отсчёта максимума за 0, как минимально возможную неотрицателньную
+
+ for (int i = 0; i < numberOrd; i++)
+ {
+ ord[i] = int.Parse(sValuesOrd[i]);
+
+ if (ord[i] > max)
+ {
+ max = ord[i]; // находим максимальный заказ среди всех
+ }
+ }
+
+ var sorted = Sort(ord, max); // переменной присваиваем вывод из метода сортировки
+
+ for (int i = 0; i < prod.Length; i++)
+ {
+ if (prod[i] >= sorted[i])
+ {
+ Console.WriteLine("no"); // если товара больше (или равно), чем максимальный заказ, выведем No
+ }
+ else
+ {
+ Console.WriteLine("yes"); // если товара меньше, чем максимальный заказ, выведем yes
+ }
+ }
+ }
+
+ public static int[] Sort(int[] ord, int max)
+ {
+ int[] sorted = new int[max]; // заносим значение максимального заказа в переменную
+ foreach (int element in ord)
+ {
+ if (element > 0)
+ {
+ sorted[element - 1] += 1; // если элемент > 0, тогда к предыдущему значению добавляем 1
+ }
+ else
+ {
+ break; // выходим
+ }
+ }
+
+ return sorted; // возвращаем отсортированный максимальный заказ
+ }
+ }
+}
diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs
index cafa825..c7fe913 100644
--- a/CourseApp/Program.cs
+++ b/CourseApp/Program.cs
@@ -7,9 +7,7 @@ public class Program
{
public static void Main(string[] args)
{
- BubbleSort.BubbleSortMethod();
-
- Console.WriteLine("Hello World");
+ Warehouse.WarehouseMethod();
}
}
-}
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index e58af8a..875e631 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,3 @@
# Tprogramming_42_2020
-Master branch :)
\ No newline at end of file
+Golyashkina Daria
\ No newline at end of file