Advertisement
nicuvlad76

3287

Feb 29th, 2020
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include<fstream>
  3. using namespace std;
  4. ifstream fin("cifrazecmax.in");
  5. ofstream fout("cifrazecmax.out");
  6. int main()
  7. {
  8.     int fr[10]= {0},fr1[10]= {0},x,i,c,p=-1;
  9.     i=0;
  10.     while(fin>>x)
  11.     {
  12.         i++;
  13.         c=x/10%10;
  14.         fr[c]++;
  15.         fr1[c]=i;
  16.     }
  17.     int maxim=0;
  18.  
  19.     for(i=0; i<=9; i++)
  20.     {
  21.         if(maxim<fr[i])
  22.         {
  23.             maxim=fr[i];
  24.             p=i;
  25.         }else
  26.         if(maxim==fr[i] and fr1[p]>fr1[i])
  27.           p=i;
  28.     }
  29.     fout<<fr1[p];
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement