AlenAntonelli

Agua para las ovejas

Sep 23rd, 2017
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. ///Alen Antonelli, Agua para las ovejas, http://www.oia.unsam.edu.ar/_media/prob/c3a03n1p2.pdf
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7.     int Norte, Sur, Este, Oeste, b, c=0;
  8.  
  9.     int x, y;
  10.     for (int i=0; i<4; i++)
  11.     {
  12.         cin>>x>>y;
  13.         if (!i)
  14.         {
  15.             Norte = Sur = x;
  16.             Este = Oeste = y;
  17.         }
  18.         if (x>Norte)
  19.             Norte = x;
  20.         if (x<Sur)
  21.             Sur = x;
  22.         if (y>Este)
  23.             Este = y;
  24.         if (y<Oeste)
  25.             Oeste = y;
  26.     }
  27.  
  28.     cin>>b;
  29.     for (int i=0; i<b; i++)
  30.     {
  31.         cin>>x>>y;
  32.         if ( (Sur<=x)&&(x<=Norte)&&(Oeste<=y)&&(y<=Este) )
  33.             c++;
  34.     }
  35.  
  36.     cout<<endl<<c;
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment