Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("datapal.in");
- ofstream fout("datapal.out");
- int f[101];
- int main()
- {
- char s[10];
- int n, i, secMax=0, nr=0;
- fin>>n;
- for(i=1; i<=n; i++)
- {
- fin>>s;
- fin.get();
- bool ok=1;
- for(int j=0; j<=3 && ok; j++)
- {
- if(s[j]!=s[7-j])
- ok=0;
- }
- //ok=1 daca data e palindrom
- if(ok==1)
- {
- //cout<<s<<"\t";
- nr++;
- int z=0;
- z=z*10 + (s[4]-'0');
- z=z*10 + (s[5]-'0');
- z=z*10 + (s[6]-'0');
- z=z*10 + (s[7]-'0');
- //cout<<z<<"\n";
- if(z%100==0)
- {
- int sec= z/100;
- f[sec]++;
- /*cout<<"Secolul: "<<sec;
- cout<<"\n";*/
- }
- else
- {
- int sec= z/100+1;
- f[sec]++;
- /*cout<<"Secolul: "<<sec;
- cout<<"\n";*/
- }
- }
- }
- fout<<nr<<"\n";
- for(int i=1; i<=101; i++)
- secMax=max(secMax, f[i]);
- for(int i=1; i<=101; i++)
- if(secMax==f[i])
- fout<<i<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment