Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main() {
- int n;
- cout << "Enter count of numbers\n";
- cin >> n;
- vector<int> a(n);
- srand(time(NULL));
- for (int i = 0; i < n; ++i)
- {
- a[i] = (rand() % 50) + 1;
- }
- sort(a.begin(), a.end());
- for (int i = 0; i < n; ++i)
- cout << a[i] << ' ';
- cout << '\n';
- int s = 0, cnt = 0;
- for (int i = 0; i < n; ++i)
- {
- if (a[i] % 2 != 0)
- s += a[i];
- if (a[i] > 25)
- ++cnt;
- }
- cout << "sum = " << s << endl;
- cout << "count = " << cnt << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement