Advertisement
STANAANDREY

bac2k21 t9 3

Jun 13th, 2022
768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream fin("bac.txt");
  5.  
  6. int main() {
  7.     int r1 = -1, r2 = -1;
  8.     for (int x; fin >> x;) {
  9.         if (x & 1) {
  10.             if (r1 == -1) {
  11.                 r1 = x;
  12.             } else if (r2 == -1) {
  13.                 r2 = x;
  14.             } else {
  15.                 r1 = r2;
  16.                 r2 = x;
  17.             }
  18.         }
  19.     }
  20.  
  21.     cout << r1 << ' ' << r2 << endl;
  22.     return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement