Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <iterator>
  4. using namespace std;
  5.  
  6. class user {
  7. private:
  8.     int age;
  9. public:
  10.     user(int age) {
  11.         this->age = age;
  12.     }
  13.  
  14.     int getAge() {
  15.         return age;
  16.     }
  17.     int getAv(int a, int b) {
  18.         return a / b;
  19.     }
  20.    
  21. };
  22.  
  23. int main()
  24. {
  25.     vector <user> users;
  26.     int enter = -5;
  27.     while (enter != -1) {
  28.         cin >> enter;
  29.         if (enter > 0)
  30.         users.push_back(user(enter));
  31.        
  32.     }
  33.    
  34.     int s1=0, min=users[0].getAge(), max=users[0].getAge(), s2=0;
  35.     for (auto a : users) {
  36.         s1+= a.getAge();
  37.         if (min > a.getAge()) min = a.getAge();
  38.         if (max < a.getAge()) max = a.getAge();
  39.         s2++;
  40.     }
  41.    
  42.  
  43.     cout << "Min  "<<min<<" Max  "<<max<<" Avrage "<<users[0].getAv(s1, s2);
  44.    
  45.    
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement