-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
106 lines (94 loc) · 3.3 KB
/
Program.cs
File metadata and controls
106 lines (94 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
namespace ConsoleApplication11
{
class math
{
struct Element
{
public int Delivery { get; set; }
public int Value { get; set; }
public static int FindMinElement(int a, int b)
{
if (a > b) return b;
if (a == b) { return a; }
else return a;
}
static void Main(string[] args)
{
int i = 0;
int j = 0;
int n;
Console.WriteLine("Введите количество A");
n = Convert.ToInt32(Console.ReadLine());
int[] a = new int[n];
Console.WriteLine("Введите количество B");
int m = Convert.ToInt32(Console.ReadLine());
int[] b = new int[m];
Element[,] C = new Element[n, m];
Console.WriteLine("Введите a[i]");
for (i = 0; i < a.Length; i++)
{
a[i] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("Введите b[i]");
for (j = 0; j < b.Length; j++)
{
b[j] = Convert.ToInt32(Console.ReadLine());
}
Console.Clear();
Console.WriteLine("Введите C[i][j]");
for (i = 0; i < n; i++)
{
for (j = 0; j < m; j++)
{
Console.Write("a[{0},{1}] = ", i, j);
C[i, j].Value = Convert.ToInt32(Console.ReadLine());
}
}
i = j = 0;
while (i < n && j < m)
{
try
{
if (a[i] == 0) { i++; }
if (b[j] == 0) { j++; }
if (a[i] == 0 && b[j] == 0) { i++; j++; }
C[i, j].Delivery = Element.FindMinElement(a[i], b[j]);
a[i] -= C[i, j].Delivery;
b[j] -= C[i, j].Delivery;
}
catch { }
}
Console.Clear();
for (i = 0; i < n; i++)
{
for (j = 0; j < m; j++)
{
if (C[i, j].Delivery != 0)
{
Console.Write("({0})", C[i, j].Delivery);
}
else
Console.Write("(0)", C[i, j].Delivery);
}
Console.WriteLine();
}
int ResultFunction = 0;
for (i = 0; i < n; i++)
{
for (j = 0; j < m; j++)
{
ResultFunction += (C[i, j].Value * C[i, j].Delivery);
}
}
Console.WriteLine("");
Console.WriteLine("Результат = {0}", ResultFunction);
i = 0;
j = 0;
int[] u = new int[n];
int[] v = new int[m];
Console.ReadLine();
}
}
}
}