|
@@ -54,7 +54,7 @@ namespace ConsoleApp1// Note: actual namespace depends on the project name.
|
|
|
{
|
|
|
Console.WriteLine("Введите " + '[' + i + ']' + " элемент: ");
|
|
|
N[i] = Convert.ToInt32(Console.ReadLine());
|
|
|
- sum2 = sum2 + N[i];
|
|
|
+ sum2 = sum2 + N[i];
|
|
|
}
|
|
|
Console.WriteLine(" ");
|
|
|
for (int i = 0; i < x; i++)
|
|
@@ -62,7 +62,56 @@ namespace ConsoleApp1// Note: actual namespace depends on the project name.
|
|
|
Console.Write("{0} ", N[i]);
|
|
|
}
|
|
|
Console.WriteLine("");
|
|
|
-
|
|
|
+ //Проверка суммы
|
|
|
+ if (sum1 == sum2)
|
|
|
+ {
|
|
|
+ Console.WriteLine("\nСуммы спроса и предложения совпадают");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Console.WriteLine("\nСуммы спроса и предложения не совпадают, задача не решаема");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int f = 0;
|
|
|
+ int[,] nm = new int[n, m];
|
|
|
+ for (int i = 0; i < n; i++)
|
|
|
+ for (int j = 0; j < m; j++)
|
|
|
+ nm[i, j] = 0;
|
|
|
+ for (int i = 0; i < n; i++)
|
|
|
+ {
|
|
|
+ for (int j = 0; j < m; j++)
|
|
|
+ {
|
|
|
+ if (M[i] > N[j])
|
|
|
+ {
|
|
|
+ nm[i, j] = N[j];
|
|
|
+ M[i] -= N[j];
|
|
|
+ N[j] -= N[j];
|
|
|
+ }
|
|
|
+ else if (M[i] < N[j])
|
|
|
+ {
|
|
|
+ nm[i, j] = M[i];
|
|
|
+ N[j] -= M[i];
|
|
|
+ M[i] -= M[i];
|
|
|
+ }
|
|
|
+ else if (M[i] == N[j])
|
|
|
+ {
|
|
|
+ nm[i, j] = M[i];
|
|
|
+ M[i] -= M[i];
|
|
|
+ N[j] -= N[j];
|
|
|
+ }
|
|
|
+ f = nm[i, j] * rp[i, j] + f;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int i = 0; i < n; i++)
|
|
|
+ {
|
|
|
+ for (int j = 0; j < m; j++)
|
|
|
+ {
|
|
|
+ Console.Write("{0}\t", nm[i, j]);
|
|
|
+ }
|
|
|
+ Console.WriteLine();
|
|
|
+ }
|
|
|
+ Console.WriteLine("");
|
|
|
+ Console.Write("Общая сумма - " + f);
|
|
|
|
|
|
}
|
|
|
}
|