ValerianBenchea

Cea mai mare cifra a unui numar

Jan 15th, 2020
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n, max=0, c;
  7.     cout<<"n="; cin>>n;
  8.     while(n!=0)
  9.     {
  10.         c=n%10;
  11.         if(c>max)
  12.             max=c;
  13.         n=n/10;
  14.     }
  15.     cout<<"Cea mai mare cifra este "<<max;
  16.  
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment