Advertisement
Chieffo

tablica 2d dynamiczna

Sep 24th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int **t = new int*[3];//inicjujemy tablice dynamiczną dwu wymiarową
  8.  
  9. t[0]=new int[3];//pierwsza kolumna z 3 komórkami
  10. t[1]=new int[3];//druga z 3
  11. t[2]=new int[3];//3 z trzema...
  12.  
  13.  
  14.  
  15. t[2][2]=1234;//do trzeciej kolumny i trzeciego wiersza wpisujemy wartość 1234
  16. cout<<t[2][2];
  17.  
  18. delete []t[0];//po kolei zwalniamy miejsce z pamięci
  19. delete []t[1];
  20. delete []t[2];
  21. delete []t;
  22.  
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement