Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("bac.txt");
- int main() {
- int last = -1, fr = 0;
- for (int x; fin >> x;) {
- if (last == -1) {
- last = x;
- }
- if (last == x) {
- fr++;
- } else {
- cout << last << ' ' << fr << ' ';
- last = x;
- fr = 1;
- }
- }
- cout << last << ' ' << fr << ' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement