Advertisement
TroubleMaker84

Untitled

May 26th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     ifstream f("BAC.txt");
  8.     struct {int a=0, p;}v[10];
  9.     int x,i=1,Vmax=0;
  10.     while (f>>x)
  11.     {
  12.         v[(x/10)%10].a++;
  13.         v[(x/10)%10].p = i;
  14.         i++;
  15.  
  16.     }
  17.  
  18.     for(i=1;i<=9;i++)
  19.         if(v[i].a>=Vmax)
  20.             Vmax=v[i].a;
  21.     for(i=1;i<=9;i++)
  22.         if(v[i].a==Vmax)
  23.             cout<<v[i].p<<' ';
  24.     f.close();
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement