Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int smallestDigit(int x) {
- if (x < 10) return x;
- int ans = smallestDigit(x / 10);
- if (ans < x % 10) return ans;
- return x % 10;
- }
- int main() {
- cout << smallestDigit(29) << endl;
- cout << smallestDigit(31415) << endl;
- cout << smallestDigit(7) << endl;
- system("pause");
- return 0;
- }
- #include <iostream>
- using namespace std;
- int mystery(int n) {
- if (n == 0)
- return 1;
- else
- return enigma(2, mystery(n - 1));
- }
- int enigma(int n1, int n2) {
- if (n1 == 0)
- return 0;
- else
- return n2 + enigma(n1 - 1, n2);
- }
- int main(){
- cout << mystery(3);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement