Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n, cifmax=-1, uc, nr;
  8.     cin>>n;
  9.     if(n==0)
  10.     {
  11.         cifmax=0;
  12.         nr=1;
  13.     }
  14.     while(n)
  15.     {
  16.         uc=n%10;
  17.         if(uc>cifmax)
  18.         {
  19.             cifmax=uc;
  20.             nr=1;
  21.         }
  22.         else if(uc==cifmax)
  23.             nr++;
  24.             n=n/10;
  25.     }
  26.     cout<<cifmax<<" "<<nr;
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement