Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int smallestDigit(int x) {
  4. if (x < 10) return x;
  5. int ans = smallestDigit(x / 10);
  6. if (ans < x % 10) return ans;
  7. return x % 10;
  8. }
  9. int main() {
  10. cout << smallestDigit(29) << endl;
  11. cout << smallestDigit(31415) << endl;
  12. cout << smallestDigit(7) << endl;
  13.  
  14.  
  15. system("pause");
  16. return 0;
  17. }
  18.  
  19. #include <iostream>
  20. using namespace std;
  21. int mystery(int n) {
  22. if (n == 0)
  23. return 1;
  24. else
  25. return enigma(2, mystery(n - 1));
  26. }
  27.  
  28. int enigma(int n1, int n2) {
  29. if (n1 == 0)
  30. return 0;
  31. else
  32. return n2 + enigma(n1 - 1, n2);
  33. }
  34.  
  35. int main(){
  36. cout << mystery(3);
  37. system("pause");
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement