Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <iterator>
- using namespace std;
- class user {
- private:
- int age;
- public:
- user(int age) {
- this->age = age;
- }
- int getAge() {
- return age;
- }
- int getAv(int a, int b) {
- return a / b;
- }
- };
- int main()
- {
- vector <user> users;
- int enter = -5;
- while (enter != -1) {
- cin >> enter;
- if (enter > 0)
- users.push_back(user(enter));
- }
- int s1=0, min=users[0].getAge(), max=users[0].getAge(), s2=0;
- for (auto a : users) {
- s1+= a.getAge();
- if (min > a.getAge()) min = a.getAge();
- if (max < a.getAge()) max = a.getAge();
- s2++;
- }
- cout << "Min "<<min<<" Max "<<max<<" Avrage "<<users[0].getAv(s1, s2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement