#include <iostream>
#include <fstream>
usingnamespace std;
int main () {
constint SIZE=100;
fstream luffy;
luffy.open("ages.dat.txt");
if (!luffy)
cerr <<"No File" <<endl;
else
cout <<"Daddy" <<endl;
char buff[SIZE];
while (luffy.getline(buff, SIZE))
cout <<buff <<endl;
luffy.close();
cout <<endl;;
luffy.open("ages.dat.txt");
while (luffy.getline(buff, SIZE)){
int number = buff[0];
int mode = number;
int count = 1;
int countMode = 1;
for (int i=1; i<SIZE; i++)
{
if (buff[i] == number)
{ // count occurrences of the current number
++count;
}
else
{ // now this is a different number
if (count > countMode)
{
countMode = count; // mode is the biggest ocurrences
mode = number;
}
count = 1; // reset count for the new number
number = buff[i];
}
}
cout << "mode : " << mode << endl;
}
}