Advertisement
STANAANDREY

bacT4 sIII 3

May 18th, 2021
863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 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 x, last;
  8.     fin >> last;
  9.     int nrap = 1;
  10.     while (fin >> x) {
  11.         if (last == x) {
  12.             nrap++;
  13.         } else {
  14.             if (nrap == 2) {
  15.                 cout << last << ' ';
  16.             }
  17.             nrap = 1;
  18.         }
  19.         last = x;
  20.     }
  21.     if (nrap == 2) {
  22.         cout << last << ' ';
  23.     }
  24.     return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement