artemgf

Досье орбитальной атаки

Apr 16th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <math.h>
  4. #include <string>
  5. #include <algorithm>
  6. #include <set>
  7.  
  8. using namespace ::std;
  9.  
  10. struct pos
  11. {
  12.     int x, y;
  13. };
  14.  
  15. bool operator<(pos p1, pos p2)
  16. {
  17.     if (p1.x == p2.x)
  18.         return p1.y < p2.y;
  19.     else
  20.         return p1.x < p2.x;
  21. }
  22. int main()
  23. {
  24.     int maxx=0, maxy=0, minx=0, miny=0, n;
  25.     set <pos> kil;
  26.  
  27.     cin >> n;
  28.  
  29.     for (int i = 1; i <= n; i++)
  30.     {
  31.         int x, y;
  32.         pos prom;
  33.         cin >> x >> y;
  34.         prom.x = x;
  35.         prom.y = y;
  36.         kil.insert(prom);
  37.         if (x > maxx)
  38.             maxx = x;
  39.         if (x < minx)
  40.             minx = x;
  41.         if (y > maxy)
  42.             maxy = y;
  43.         if (y < miny)
  44.             miny= y;
  45.     }
  46.  
  47.     for (int y = maxy; y >= miny; y--)
  48.     {
  49.         for (int x = minx; x <= maxx; x++)
  50.         {
  51.             pos prom;
  52.             prom.x = x;
  53.             prom.y = y;
  54.             if (kil.find(prom) != kil.end())
  55.                 cout << "*";
  56.             else
  57.                 if (x == 0 && y != 0)
  58.                     cout << "|";
  59.                 else
  60.                     if (x != 0 && y == 0)
  61.                         cout << "-";
  62.                     else
  63.                         if (y == 0 && x == 0)
  64.                             cout << "+";
  65.                         else
  66.                             cout << ".";
  67.         }
  68.         cout << endl;
  69.     }
  70.  
  71.    
  72.     return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment