Lucian_Adrian

Untitled

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