Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <deque>
- #include <algorithm>
- using namespace std;
- int mx;
- // проверяет, равен ли х максимуму
- bool ismax(int x) {
- return x == mx;
- }
- // проверяет, является ли четным
- bool iseven(int x) {
- return x % 2 == 0;
- }
- int main() {
- // считываем количество элементов в последовательности
- int n;
- cin >> n;
- deque<int> d;
- for (int i = 0; i < n; ++i) {
- int x;
- cin >> x;
- d.push_back(x);
- }
- // удаление элементов равных максимальному
- mx = *max_element(d.begin(), d.end());
- d.erase(remove_if(d.begin(), d.end(), ismax), d.end());
- cout << "Sequence after removing maximum elements:" << endl;
- for (auto it = d.begin(); it != d.end(); ++it) {
- cout << *it << " ";
- }
- cout << endl;
- // сортировка
- sort(d.begin(), d.end());
- cout << "Sorted sequence:" << endl;
- for (auto it = d.begin(); it != d.end(); ++it) {
- cout << *it << " ";
- }
- cout << endl;
- // удаление повторяющихся элементов
- d.erase(unique(d.begin(), d.end()), d.end());
- cout << "Sequence after removing repeating elements:" << endl;
- for (auto it = d.begin(); it != d.end(); ++it) {
- cout << *it << " ";
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement