int main(){ srand(time(NULL)); int **arr, N, M; cout << "N : "; cin >> N; cout << "M : "; cin >> M; arr = new int *[N]; for(int i = 0; i < M ; i++) arr[i] = new int [M];
for(int i = 0; i < N ; i++) for(int j = 0; j < M ; j++) arr[i][j] = rand() % 150; cout << "your array : " << endl; for(int i = 0; i < N ; i++){ for(int j = 0; j < M ; j++) cout << arr[i][j] << "\t"; cout << endl; } cout << "your NEW array : " << endl; for(int i = 0; i < N ; i++){ for(int j = 0; j < M ; j++) cout << arr[j][i] << "\t"; cout << endl; } cout << endl; }
#include<iostream>
#include<ctime>
using namespace std;
int main(){
srand(time(NULL));
int **arr, N, M;
cout << "N : ";
cin >> N;
cout << "M : ";
cin >> M;
arr = new int *[N];
for(int i = 0; i < M ; i++)
arr[i] = new int [M];
for(int i = 0; i < N ; i++)
for(int j = 0; j < M ; j++)
arr[i][j] = rand() % 150;
cout << "your array : " << endl;
for(int i = 0; i < N ; i++){
for(int j = 0; j < M ; j++)
cout << arr[i][j] << "\t";
cout << endl;
}
cout << "your NEW array : " << endl;
for(int i = 0; i < N ; i++){
for(int j = 0; j < M ; j++)
cout << arr[j][i] << "\t";
cout << endl;
}
cout << endl;
}
int **arr, N, M;
cout << "N : ";
cin >> N;
cout << "M : ";
cin >> M;
arr = new int *[N];
for(int i = 0; i < M ; i++)
arr[i] = new int [M];
for(int i = 0; i < N ; i++)
for(int j = 0; j < M ; j++)
arr[i][j] = rand() % 150;
cout << "your array : " << endl;
for(int i = 0; i < N ; i++){
for(int j = 0; j < M ; j++)
cout << arr[i][j] << "\t";
cout << endl;
}
cout << "your NEW array : " << endl;
for(int i = 0; i < N ; i++){
for(int j = 0; j < M ; j++)
cout << arr[j][i] << "\t";
cout << endl;