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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
| #include "stdafx.h"
using namespace std;
int summ(int** A,int** B,int** C);//функция сложения матриц
int** A; //Первая матрица
int** B; //вторая матрица
int** C; // результат операции
void vvodA(int m, int n);//ввод матрицы 1
void vvodB(int m, int n);//ввод матрицы 2
int razn(int** A, int** B, int** C); //функция вычитания матриц
int proizved(int** A, int** B, int** C); //функция умножения
int strok; //количество строк
int stolb; //количество столбцов
string temp_operator; //переменная для выбора пункта меню
int _tmain(int argc, _TCHAR* argv[])
{ setlocale(LC_ALL, "Russian");
while(1)
{
cout << "Введите операцию:" << endl;
cout << "1)Сложение" << endl;
cout << "2)Вычитание" << endl;
cout << "3)Возведение в степень" << endl;
cout << "4)Транспанирование" << endl;
cout << "5)Замена строки" << endl;
cout << "6)Проверка равенства" << endl;
cout << "7)добавление нового столбца" << endl;
cout << "8)Умножение" << endl;
cout << "9)Выход" << endl;
cin>>temp_operator;
if(temp_operator.length()==1)
{ int tempdeystvie=atoi(temp_operator.c_str());
switch (tempdeystvie)
{ case 1:cout << "Это сумма" << endl;
cout << "Введите количество строк: " << endl;
cin >> strok;
cout << "Введите количество столбцов: " << endl;
cin >> stolb;
vvodA(strok, stolb);
vvodB(strok, stolb);
summ(A,B,C);
break;
case 2:cout << "Это разность"<< endl;
cout << "Введите количество строк: " << endl;
cin >> strok;
cout << "Введите количество столбцов: " << endl;
cin >> stolb;
vvodA(strok, stolb);
vvodB(strok, stolb);
razn(A,B,C);
break;
case 3:cout << "Это возведение в степень"<< endl;
break;
case 4:cout << "Это транспанировани"<< endl;
break;
case 5:cout << "Это замена строки"<< endl;
break;
case 6:cout << "Проверка равенства"<< endl;
break;
case 7:cout << "Это замена столбца"<< endl;
break;
case 8:cout << "Это умножение"<< endl;
cout << "Введите количество строк: " << endl;
cin >> strok;
cout << "Введите количество столбцов: " << endl;
cin >> stolb;
vvodA(strok, stolb);
vvodB(strok, stolb);
proizved(A,B,C);
break;
case 9:exit(NULL);
break;
}
}
else
{
cout << "Ошибка ввода. Повторите"<<endl;
}
}
return NULL;
}
void vvodA(int m, int n)
{ A=new int*[m];
for(int i=0; i<m; i++)
{
A[i] = new int [n];
}
for(int y=0;y<m;y++)
{
for(int x=0;x<n;x++)
{
cout << "Введите A[" << y << ' ' << x <<"]: ";
cin >> A[y][x];
}
}
cout << '\n';
cout << "A[" << m << ' ' << n <<"]: "<<endl;
for(int y=0;y<m;y++)
{
for(int x=0;x<n;x++)
{
cout << A[y][x] << ' ';
}
cout << '\n';
}
}
void vvodB(int m, int n)
{ B=new int*[m];
for(int i=0; i<m; i++)
{
B[i] = new int [n];
}
for(int y=0;y<m;y++)
{
for(int x=0;x<n;x++)
{
cout << "Введите B[" << y << ' ' << x <<"]: ";
cin >> B[y][x];
}
}
cout << '\n';
cout << "B[" << m << ' ' << n <<"]: "<<endl;
for(int y=0;y<m;y++)
{
for(int x=0;x<n;x++)
{
cout << B[y][x] << ' ';
}
cout << '\n';
}
}
int summ(int** A,int** B, int** C)
{
C=new int*[strok];
for(int i=0; i<strok; i++)
{
C[i] = new int [stolb];
}
for(int i=0; i < strok ; i++)
{
for(int j=0; j < stolb ; j++)
{
C[i][j] = A[i][j] + B[i][j];
}
}
cout << "Результат сложения: C[" << strok << "] ["<< stolb<< "]" << endl;
for(int i=0; i < strok ; i++)
{
for(int j=0; j < stolb ; j++)
{
cout << C[i][j] << " ";
}
cout << '\n';
}
getchar();
return 0 ;
}
int razn(int** A,int** B, int** C)
{
C=new int*[strok];
for(int i=0; i<strok; i++)
{
C[i] = new int [stolb];
}
for(int i=0; i < strok ; i++)
{
for(int j=0; j < stolb ; j++)
{
C[i][j] = A[i][j] - B[i][j];
}
}
cout << "Результат вычитания: C[" << strok << "] ["<< stolb<< "]" << endl;
for(int i=0; i < strok ; i++)
{
for(int j=0; j < stolb ; j++)
{
cout << C[i][j] << " ";
}
cout << '\n';
}
getchar();
return 0 ;
}
int proizved(int** A, int** C, int** B) |