Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include<iostream>
  2. #include<memory>
  3. using namespace std;
  4.  
  5. char crt[] = "------------------ \n";
  6.  
  7. void main() {
  8.  
  9. int *p1 = new int[5];
  10.  
  11. for (int i = 0; i < 5; i++)
  12. {
  13. p1[i] = 10;
  14. }
  15.  
  16. cout << "PRVA: " << endl;
  17. for (int i = 0; i < 5; i++)
  18. {
  19. cout << p1[i] << endl;
  20. }
  21. cout << crt;
  22.  
  23. int **p2;
  24. p2 = new int*[5];
  25. for (int i = 0; i < 5; i++)
  26. {
  27. p2[i] = new int;
  28. *p2[i] = i;
  29. }
  30.  
  31. cout << "DRUGA: " << endl;
  32. for (int i = 0; i < 5; i++)
  33. {
  34.  
  35. cout << *p2[i] << endl;
  36. }
  37. cout << crt;
  38.  
  39.  
  40. int *p3[10];
  41. for (int i = 0; i < 10; i++)
  42. {
  43. p3[i] = new int;
  44. *p3[i] = 30;
  45. }
  46.  
  47. cout << "TRECA: " << endl;
  48. for (int i = 0; i < 10; i++)
  49. {
  50.  
  51. cout << *p3[i] << endl;
  52. }
  53. cout << crt;
  54.  
  55. shared_ptr<int> p4;
  56. p4 = make_shared<int>();
  57.  
  58. *p4 = 111;
  59.  
  60. cout << "CETVRTA: " << endl;
  61. cout << *p4 << endl;
  62.  
  63. cout << crt;
  64.  
  65. shared_ptr<int>p5[10];
  66. for (int i = 0; i < 10; i++)
  67. {
  68. p5[i] = make_shared<int>();
  69. *p5[i] = 40;
  70. }
  71.  
  72. cout << "PETA: " << endl;
  73. for (int i = 0; i < 10; i++)
  74. {
  75.  
  76. cout<<*p5[i] << endl;
  77. }
  78. cout << crt;
  79.  
  80. shared_ptr<int> *p6;
  81. p6 = new shared_ptr<int>[10];
  82. for (int i = 0; i < 10; i++)
  83. {
  84. p6[i] = make_shared<int>();
  85. *p6[i] = 50;
  86. }
  87.  
  88. cout << "SESTA: " << endl;
  89. for (int i = 0; i < 10; i++)
  90. {
  91.  
  92. cout << *p6[i] << endl;
  93. }
  94. cout << crt;
  95. system("pause>0");
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement