Advertisement
J00ker

(10-21)T

Oct 20th, 2014
32
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 put(int a, int n)
  6. {
  7. if(n <= 0) return 1;
  8. else
  9. {
  10. n--;
  11. return put(a, n) * a;
  12. }
  13. }
  14.  
  15. int CMMDC(int a, int b)
  16. {
  17. if(!(a % b)) return b;
  18. else return CMMDC(b, a%b);
  19. }
  20.  
  21. int NrC(int n)
  22. {
  23. if(n == 0) return 0;
  24. return NrC(n / 10) + 1;
  25. }
  26.  
  27. int Oglindit(int n)
  28. {
  29. int p = NrC(n);
  30. if(n < 10) return n;
  31. else
  32. {
  33. p--;
  34. return (n % 10) * put(10, p) + Oglindit(n/10);
  35. }
  36.  
  37. }
  38.  
  39. int main()
  40. {
  41. cout << put(2, 10) << "\n\n";
  42. cout << CMMDC(5, 15) << "\n\n";
  43. cout << Oglindit(123456) << "\n\n";
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement