Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DYNAMICZNA TABLICA 2D
- int main() {
- srand(time(NULL));
- int n, w;
- cout << "Podaj liczbe wierszy:";
- cin >> n;
- cout << "Podaj liczbe kolumn:";
- cin >> w;
- int* *tab = new int *[n];
- for (int i = 0; i < n; i++)
- tab[i] = new int[w] {};
- for (int i = 0; i < n; i++)
- for(int j=0;j<w;j++){
- cout << "Podaj element [" << i << "]["<<j<<"]: ";
- cin >> tab[i][j];
- }
- int** tab2 = new int* [w];
- for (int i = 0; i < w; i++)
- tab2[i] = new int[n] {};
- for (int i = 0; i < w; i++)
- for (int j = 0; j < n; j++) {
- tab2[i][j] = tab[j][i];
- }
- cout << endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < w; j++)
- cout << tab[i][j]<<" ";
- cout << endl;
- }
- cout << endl;
- for (int i = 0; i < w; i++) {
- for (int j = 0; j < n; j++)
- cout << tab2[i][j] << " ";
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement