Advertisement
Dani_info

cifra max a n numere

Nov 26th, 2017
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.    int n, i, k, uc, cmax;
  8.    cout<<"Cate numere doriti sa se citeasca??"<<endl;
  9.    cin>>k;
  10.    for(i=1; i<=k; i++)
  11.    {
  12.        cout<<"n="<<endl;  cin>>n;
  13.        uc=n%10;
  14.        cmax=uc;
  15.        while(n!=0)
  16.        {
  17.            n=n%10;
  18.            if(uc>cmax)
  19.            cmax=uc;
  20.            n=n/10;
  21.            cout<<"Cifra maxima este:"<<cmax<<endl;
  22.        }
  23.    }
  24.     return 0;
  25. }
Advertisement
RAW Paste Data Copied
Advertisement