Advertisement
newvol

list

Apr 27th, 2023
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.     list <int> l(n);
  9.     for (int i = 0; i < n; i++) {
  10.         int x;
  11.         cin >> x;
  12.         l.push_back(x);
  13.     }
  14.     int pos;
  15.     cin >> pos;
  16.     int k = 0;
  17.     int x;
  18.     for (auto it = l.begin(); it != l.end(); it++) {
  19.         k += 1;
  20.         if (k == pos) {
  21.             x = *it;
  22.         }
  23.     }
  24.     for (auto it = l.begin(); it != l.end(); it++) {
  25.         if(*it > x) {
  26.             cout << *it << endl;
  27.         }
  28.     }
  29.     return 0;
  30. }
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement