Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main() {
- int number, sumNumbers = 0;
- string line;
- getline(cin, line);
- istringstream stream(line);
- vector<int> numbers;
- while (stream >> number) {
- numbers.push_back(number);
- sumNumbers += number;
- }
- numbers.erase(remove_if(numbers.begin(), numbers.end(), [&](const int& i) {
- return i <= ((double)sumNumbers / numbers.size());
- }), numbers.end());
- sort(numbers.begin(), numbers.end(), greater<int>());
- if (numbers.size() == 0) {
- cout << "No" << endl;
- }
- else {
- for (int i = 0; i < (numbers.size() < 5? numbers.size() : 5); i++) {
- cout << numbers[i] << ' ';
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement