Lucian_Adrian

https://www.pbinfo.ro/probleme/2288/cifraimparamaxima

Oct 19th, 2021
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5. int n;
  6. cin >> n;
  7. int cmax= -1;
  8. while(n){
  9. if(n % 2 == 1)
  10. if(n%10>cmax)
  11. cmax = n%10;
  12. n /= 10;
  13. }
  14. if(cmax == -1)
  15. cout << "nu exista";
  16. else
  17. cout << cmax << endl;
  18.  
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment