Advertisement
yejolga

ol_5_06

Nov 8th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ifstream cin("input.txt");
  10.  
  11.     int n;
  12.     cin>>n;
  13.     int a[n];
  14.     for(int i = 0; i < n; i++)
  15.         cin>>a[i];
  16.  
  17.     int m;
  18.     cin>>m;
  19.     for(int j = 0; j < m; j++)
  20.     {
  21.         char c;
  22.         cin>>c;
  23.         int cur;
  24.         cin>>cur;
  25.         if (c == '<')
  26.         {
  27.             for(int i = 0; i < n; i++)
  28.                 if(a[i] < cur)
  29.                 cout<<a[i]<<' ';
  30.             cout<<'\n';
  31.         }
  32.         else if (c == '>')
  33.         {
  34.             for(int i = 0; i < n; i++)
  35.                 if(a[i] > cur)
  36.                 cout<<a[i]<<' ';
  37.             cout<<'\n';
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement