Объяснение:
#include <iostream>
#include <ctime>
#include <vector>
using namespace std;
int main()
{
srand(time(NULL));
int rows, cols;
cin >> rows >> cols;
cout << endl;
int** arr = new int*[rows];
vector <int> result;
for (int i = 0; i < rows; i++)
arr[i] = new int [cols];
}
for (int j = 0; j < cols; j++)
arr[i][j] = rand() % 100;
cout.width(3);
cout << arr[i][j];
for (int i = 0; i < cols; i++)
for (int j = 0; j < rows; j++)
result.push_back(arr[j][i]);
for (const auto& element : result)
cout << element << " ";
delete[] arr[i];
delete[] arr;
Объяснение:
#include <iostream>
#include <ctime>
#include <vector>
using namespace std;
int main()
{
srand(time(NULL));
int rows, cols;
cin >> rows >> cols;
cout << endl;
int** arr = new int*[rows];
vector <int> result;
for (int i = 0; i < rows; i++)
{
arr[i] = new int [cols];
}
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
arr[i][j] = rand() % 100;
cout.width(3);
cout << arr[i][j];
}
cout << endl;
}
for (int i = 0; i < cols; i++)
{
for (int j = 0; j < rows; j++)
{
result.push_back(arr[j][i]);
}
}
cout << endl;
for (const auto& element : result)
{
cout << element << " ";
}
for (int i = 0; i < rows; i++)
{
delete[] arr[i];
}
delete[] arr;
}