Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream> // file stream
- using namespace std;
- int main()
- {
- ifstream fin("bac.in"); // input file stream
- ofstream fout("bac.out");
- int numarAparitii = 1;
- int numarCurent, numarAnterior;
- fin >> numarCurent;
- numarAnterior = numarCurent;
- while (fin >> numarCurent) {
- if (numarCurent == numarAnterior) {
- numarAparitii++;
- } else {
- fout << numarAnterior << " " << numarAparitii << endl;
- numarAnterior = numarCurent;
- numarAparitii = 1;
- }
- }
- fout << numarAnterior << " " << numarAparitii << endl;
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment