pjobro

2D dinamicko polje

Mar 15th, 2017
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <vector>
  4. #include <list>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int x, y;
  11.     cout << "unesite velicinu polja: ";
  12.     cin >> x >> y;
  13.  
  14.     int **p_p_polje = new int*[x];
  15.  
  16.     for (int i = 0; i < x; i++)
  17.     {
  18.         p_p_polje[i] = new int[y];
  19.     }
  20.     for (int i = 0; i < x; i++)
  21.     {
  22.         for (int j = 0; j < y; j++)
  23.         {
  24.             cout << "unesite vrijednost polja{" << i << "], [" << j << "]: ";
  25.             cin >> p_p_polje[i][j];
  26.         }
  27.     }
  28.     for (int i = 0; i < x; i++)
  29.     {
  30.         for(int j=0;j<y;j++)
  31.         {
  32.             cout << p_p_polje[i][j] << "\t";
  33.  
  34.         }
  35.         cout << endl;
  36.     }
  37.     for (int i = 0; i < x; i++)
  38.     {
  39.         delete p_p_polje[i];
  40.  
  41.     }
  42.     delete p_p_polje;
  43.     p_p_polje = nullptr;
  44.  
  45.    
  46. }
Add Comment
Please, Sign In to add comment