Răspuns:
#include <fstream>
#include <cstring>
ifstream fin("date.in");
ofstream fout("date.out");
using namespace std;
int main()
{
string a;
fin >> a;
char curchar = a[0], ans = a[0];
int count = 1;
int maxi = 0;
for(int i = 1; i < a.size(); i++){
if(a[i] == curchar) count++;
else count = 1, curchar = a[i];
if(count > maxi){
maxi = count;
ans = curchar;
}
}
for(int i = 0; i < maxi; i++) fout << ans;
}
Explicație:
In C++, poti folosi container-ul std::string. E alocat dinamic si poti citi fara a declara marimea anterior. Are proprietati diverse precum string::size, string::find. Trebuie sa ai tagul C++11 activ in compilator.