Advertisement
Ahmet_Durmic

palindrom_rekurzivno

Apr 3rd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int obrnuti_broj=0;
  6. void obrnuti(int x){
  7. int y;
  8. if(x==0){
  9.  
  10. }else{
  11. y=x%10;
  12. obrnuti_broj=(obrnuti_broj*10)+y;
  13. obrnuti(x/10);
  14. }
  15. }
  16.  
  17. bool palindrom(int x,int y){
  18. if(x==y){
  19. return true;
  20. }else{
  21. return false;
  22. }
  23. }
  24.  
  25.  
  26. int main(){
  27.  
  28. int x;
  29. cout<<"Unesite broj za provjeru: ";
  30. cin>>x;
  31. obrnuti(x);
  32. if(palindrom(x,obrnuti_broj)){
  33. cout<<"Broj je palindrom.";
  34. }else{
  35. cout<<"Broj nije palindrom. ";
  36. }
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement