Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream read("bac.txt");
- int n=0, a;
- while (!read.eof())
- {
- read>>a;
- n++;
- }
- read.clear();
- read.seekg(0, read.beg);
- int edd[n];
- for (int w1=0; w1<=n; w1++)
- {
- edd[w1]=1;
- }
- int num, elozo;
- read>>a;
- num=a;
- int s;
- for(s=1; !read.eof(), s<=n; elozo=a)
- {
- read>>a;
- if (a==elozo)
- {
- edd[s]++;
- }
- else
- {
- s++;
- }
- if (edd[s]>edd[s-1])
- {
- num=a;
- }
- }
- int maxim=0;
- for (int h=0; h<=s; h++)
- {
- if (edd[h]>maxim)
- {
- maxim=edd[h];
- }
- }
- cout << maxim << endl;
- for (int k=1; k<=maxim; k++)
- {
- cout<< num <<" ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement