Advertisement
Guest User

Untitled

a guest
Jan 27th, 2021
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6. int num = 0, num_unit = 0, num_cp = 0, num_div_cp = 0, capicua = 1, num_div = 100000;
  7.  
  8. cout<<"Numero: "; cin>>num;
  9. while(num != 0){
  10. if(num >= num_div){
  11. num_cp = num;
  12. num_div_cp = num_div;
  13. num_unit = num / num_div;
  14. while(!(num_cp < 10)){
  15. num_cp %= num_div_cp;
  16. num_div_cp /= 10;
  17. }
  18. num_cp -= num_unit;
  19. if(num_cp != 0){
  20. capicua = 0;
  21. break;
  22. }
  23. num %= num_div;
  24. num -= num_unit;
  25. num /= 10;
  26. }else{
  27. num_div /= 10;
  28. }
  29. }
  30. if(capicua == 1){
  31. cout<<"Es capicua"<<endl;
  32. }else{
  33. cout<<"No es capicua"<<endl;
  34. }
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement