все работает, кроме вывода последней матрицы "transpose dinMass:", она просто не выводится
#include <iostream>
#include <iomanip>
using namespace std;
void transpose(int matrix[4][4]){
int t;
for(int i = 0; i < 4; ++i){
for(int j = i; j < 4; ++j){
t = matrix[i][j];
matrix[i][j] = matrix[j][i];
matrix[j][i] = t;
}
}
}
void transpose1(int(* matrix)[4]){
int t;
for(int i = 0; i < 4; ++i){
for(int j = i; j < 4; ++j){
t = matrix[i][j];
matrix[i][j] = matrix[j][i];
matrix[j][i] = t;
}
}
}
void transpose2 (int **matrix, size_t m,size_t n){
int t;
for(int i = 0; i < m; ++i){
for(int j = i; j < n; ++j){
t = matrix[i][j];
matrix[i][j] = matrix[j][i];
matrix[j][i] = t;
}
}
}
int main(){
const int n(4), m(4);
int **dinMass = new int*[4];
int statMass[n][m];
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
int value = 1+rand() % 11;
statMass[i][j] = value;
**dinMass = value;
}
}
cout << "Adresses:" << endl;
cout << "statMass = " << endl;
for (int i = 0; i < n; ++i){
for (int j = 0; j < m; j++){
cout << setw(10) << statMass << " ";
}
cout << endl;
}
cout << "dinMass = " << endl;
for (int i = 0; i < n; ++i){
for (int j = 0; j < m; j++){
cout << setw(10) << dinMass << " ";
}
cout << endl;
}
//---------------------------------------------
transpose(statMass);
cout << "transpose 1 statMass:" << endl;
for(int i = 0; i < 4; ++i){
for(int j = 0; j < 4; ++j)
cout << setw(10) << statMass[i][j];
cout << endl;
}
transpose1(statMass);
cout << "transpose 2 statMass:" << endl;
for(int i = 0; i < 4; ++i){
for(int j = 0; j < 4; ++j)
cout << setw(10) << statMass[i][j];
cout << endl;
}
//---------------------------------------------
transpose2 (dinMass, 4, 4);
cout << "transpose dinMass:" << endl;
for(int i = 0; i < 4; ++i){
for(int j = 0; j < 4; ++j)
cout << setw(10) << dinMass[i][j];
cout << endl;
}
for (int i = 0; i < 4; i++)
delete[] dinMass[i];
delete[] dinMass;
}