Advertisement
RobertDeMilo

RB3.4 Оператор delete

Apr 16th, 2024
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <vector>
  5. #include <random>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int n;
  11.     cin >> n;
  12.  
  13.     mt19937_64  random_gen;
  14.     uint64_t sum = 0;
  15.  
  16.     /*for (int i = 0; i < n; ++i)
  17.     {
  18.         uint64_t x = random_gen();
  19.         sum += x;
  20.     }*/
  21.  
  22.     for (int i = 0; i < n; ++i)
  23.     {
  24.         auto x = new uint64_t;
  25.         *x = random_gen();
  26.         sum += *x;
  27.         delete x;
  28.     }
  29.  
  30.     cout << sum;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement