Advertisement
evcamels

lr-4

Nov 17th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. class lr{
  5.     vector <int> a;
  6.     static int count;
  7. public:
  8.     void get(int n){
  9.             for(int i=0;i<n;i++){
  10.             int temp;
  11.             cin >> temp;
  12.             a.push_back(temp);
  13.         }
  14.     }
  15.     void sum(){
  16.         for(int i=0;i<a.size();i++){
  17.             count+=a[i];
  18.         }
  19.     }
  20.     static int getCount(){
  21.         return count;
  22.     }
  23.     ~lr(){
  24.         count--;
  25.         auto size = a.size();
  26.         a.resize(0);
  27.         a.resize(size);
  28.     }
  29.    
  30. };
  31. int main(int argc, const char * argv[]) {
  32.     vector <int> a;
  33.     int n;
  34.     cin >> n;
  35.     lr oo;
  36.     oo.get(n);
  37.     oo.sum();
  38.     oo.getCount();
  39.     oo.~lr();
  40.     return 0;
  41. }
  42.  
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement