@miriganua
131 / 102 / 4
Регистрация: 05.02.2012
Сообщений: 241
|
16.01.2013, 00:33
|
|
Попробуй так:
C++ | 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
| #include <iostream>
#include <windows.h>
using namespace std;
void main()
{
SetConsoleOutputCP(1251);
const int Y = 3, X = 4;
int a[Y][X];
cout << "Заполните двумерный масиив:\n";
for(int i = 0; i < Y; i++)
{
for(int j = 0; j < X; j++)
{
cout << "a[" << i << "][" << j << "] = ";
cin >> a[i][j];
}
}
cout << "Результат:\n";
int a1;
int a2;
cout << "Введите строки, которые нужно поменять местами:";
cin >> a1;
cin >> a2;
for (int j = 0; j < X; j++)
{
int b = a[a1][j];
a[a1][j] = a[a2][j];
a[a2][j] = b;
}
for (int i = 0; i < Y; i++)
{
for (int j = 0; j < X; j++)
{
cout << a[i][j] << " ";
}
cout << '\n';
}
} |
|
3
|