Advertisement
angelavaida27

Var59_SII_Ex5

Nov 18th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <climits>
  4. using namespace std;
  5. int ap[11];
  6. char alt[55];
  7. int main ()
  8. {
  9.     int i, n, nr, j, maxim=INT_MIN, k;
  10.     cin.getline(alt, 55);
  11.     n=strlen(alt);
  12.     for (i=0; i<n; i++)
  13.     {
  14.         if (strchr("1234567890", alt[i])!=0)
  15.         {
  16.             nr=alt[i]-48;
  17.             ap[nr]++;
  18.         }
  19.     }
  20.     for (j=0; j<=9; j++)
  21.     {
  22.         if (ap[j]>maxim)
  23.         {
  24.             k=j;
  25.             maxim=ap[j];
  26.         }
  27.     }
  28.     cout<<k;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement