#include <iostream>
#include <time.h>
using namespace std;
int main()
{
srand(time(0));
int a, b;
int min = 100, posI, posJ;
cin >> a >> b;
int** matrix = new int*[a];
for (int i = 0; i < a; i++)
matrix[i] = new int[b];
for (int j = 0; j < b; j++)
matrix[i][j] = rand() % min;
}
cout << matrix[i][j] << '\t';
cout << endl;
if (matrix[i][j] < min)
posI = i;
posJ = j;
min = matrix[i][j];
matrix[posI][posJ] = matrix[0][0];
matrix[0][0] = min;
delete[] matrix[i];
delete[] matrix;
system("pause");
return 0;
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
srand(time(0));
int a, b;
int min = 100, posI, posJ;
cin >> a >> b;
int** matrix = new int*[a];
for (int i = 0; i < a; i++)
matrix[i] = new int[b];
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
matrix[i][j] = rand() % min;
}
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
cout << matrix[i][j] << '\t';
cout << endl;
}
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
if (matrix[i][j] < min)
{
posI = i;
posJ = j;
min = matrix[i][j];
}
}
matrix[posI][posJ] = matrix[0][0];
matrix[0][0] = min;
cout << endl;
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
cout << matrix[i][j] << '\t';
cout << endl;
}
for (int i = 0; i < a; i++)
delete[] matrix[i];
delete[] matrix;
system("pause");
return 0;
}