Advertisement
STANAANDREY

4/191 perechi

Nov 5th, 2019
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. ifstream fin("PERECHI.txt");
  6.  
  7. typedef struct
  8. {
  9.     unsigned x, y;
  10. } PER;
  11.  
  12. int main()
  13. {
  14.     PER p[100];
  15.     unsigned n, i;
  16.     fin >> n;
  17.     for (i = 0; i < n; i++)
  18.         fin >> p[i].x >> p[i].y;
  19.  
  20.     for (i = 0; i < n; i++)
  21.     {
  22.         int x = p[i].x;
  23.         int y = p[i].y;
  24.         int inv = 0;
  25.  
  26.         while (y)
  27.         {
  28.             inv = 10 * inv + y % 10;
  29.             y /= 10;
  30.         }
  31.  
  32.         if (x == inv)
  33.             cout << p[i].x << ' ' << p[i].y << endl;
  34.     }
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement