ValerianBenchea

+++datapal

Feb 11th, 2020
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream fin("datapal.in");
  5. ofstream fout("datapal.out");
  6. int f[101];
  7. int main()
  8. {
  9.     char s[10];
  10.     int n, i, secMax=0, nr=0;
  11.  
  12.     fin>>n;
  13.     for(i=1; i<=n; i++)
  14.     {
  15.         fin>>s;
  16.         fin.get();
  17.         bool ok=1;
  18.         for(int j=0; j<=3 && ok; j++)
  19.         {
  20.             if(s[j]!=s[7-j])
  21.                 ok=0;
  22.         }
  23.  
  24.         //ok=1 daca data e palindrom
  25.         if(ok==1)
  26.         {
  27.             //cout<<s<<"\t";
  28.             nr++;
  29.             int z=0;
  30.             z=z*10 + (s[4]-'0');
  31.             z=z*10 + (s[5]-'0');
  32.             z=z*10 + (s[6]-'0');
  33.             z=z*10 + (s[7]-'0');
  34.             //cout<<z<<"\n";
  35.  
  36.             if(z%100==0)
  37.             {
  38.                 int sec= z/100;
  39.                 f[sec]++;
  40.                 /*cout<<"Secolul: "<<sec;
  41.                 cout<<"\n";*/
  42.             }
  43.             else
  44.             {
  45.                 int sec= z/100+1;
  46.                 f[sec]++;
  47.                 /*cout<<"Secolul: "<<sec;
  48.                 cout<<"\n";*/
  49.             }
  50.  
  51.         }
  52.  
  53.     }
  54.     fout<<nr<<"\n";
  55.     for(int i=1; i<=101; i++)
  56.         secMax=max(secMax, f[i]);
  57.     for(int i=1; i<=101; i++)
  58.         if(secMax==f[i])
  59.             fout<<i<<" ";
  60.  
  61.  
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment