В C++ #include <iostream> #include <iomanip> #include <ctime> int main() { using namespace std;
const int N = 5; const int M = 5;
//Создаём массив и как-нибудь заполняем int A[N][M]; srand(time(0)); for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) A[i][j] = rand() % (N * M) + 1;
//Выводим его на экран for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cout << setw(4) << A[i][j]; cout << endl; }
//Меняем местами 2ю и 3ю строки int temp = 0; for (int j = 0; j < M; ++j) { temp = A[1][j]; A[1][j] = A[2][j]; A[2][j] = temp; }
//Выводим полученный массив на экран cout << "\n\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cout << setw(4) << A[i][j]; cout << endl; }
#include <iostream>
#include <iomanip>
#include <ctime>
int main()
{
using namespace std;
const int N = 5;
const int M = 5;
//Создаём массив и как-нибудь заполняем
int A[N][M];
srand(time(0));
for (int i = 0; i < N; ++i)
for (int j = 0; j < M; ++j)
A[i][j] = rand() % (N * M) + 1;
//Выводим его на экран
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < M; ++j)
cout << setw(4) << A[i][j];
cout << endl;
}
//Меняем местами 2ю и 3ю строки
int temp = 0;
for (int j = 0; j < M; ++j)
{
temp = A[1][j];
A[1][j] = A[2][j];
A[2][j] = temp;
}
//Выводим полученный массив на экран
cout << "\n\n";
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < M; ++j)
cout << setw(4) << A[i][j];
cout << endl;
}
return 0;
}