Advertisement
STANAANDREY

bacT11 SIII 3

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