Код:
#include <iostream>
#include <ctime>
#include <iomanip>
using namespace std;
int** form_mas2(int& nstr, int& nstb)
{
cout << "Введите кол-во строк и столбцов ";
cin >> nstr;
cin >> nstb;
int** mas2 = new int* [nstr + 1];
for (int i = 0; i < nstr; i++)
mas2[i] = new int[nstb];
return mas2;
}
void input_mas2(int** mas2, int& nstr, int& nstb)
{
for (int i = 0; i < nstr; i++)
for (int j = 0; j < nstb; j++)
mas2[i][j] = rand() % 10-5;
}
void print_mas2(int** mas2, int& nstr, int nstb)
{
for (int i = 0; i < nstr; i++) {
for (int j = 0; j < nstb; j++)
cout << setw(3) << mas2[i][j] << ' ';
cout << endl;
}
cout << endl;
}
int main()
{
setlocale(LC_ALL, "russian");
int** mas2 = new int*[nstr];
for (int i = 0; i < nstr; i++)
{
mas2[i] = new int[nstb];
}
form_mas2(nstr, nstb);
input_mas2(mas2, nstr, nstb);
print_mas2(mas2, nstr, nstb);
for (int j = 0; j < nstb; j += 2)//2
{
for (int i = 0; i < nstr / 2; i++)//1
{
int tmp = mas2[i][j];//
mas2[i][j] = mas2[nstr - 1 - i][j];
mas2[nstr - 1 - i][j] = tmp;
}
cout << endl;
for (int i = 0; i < nstr; i++)
{
for (int j = 0; j < nstr; j++)
cout << mas2[i][j] << " ";
cout << endl;
}
return 0;
}