Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int rekurzija(int x) {
- if(x == 0) {
- return 0;
- }
- int cifra = x % 10;
- if(cifra == 5) {
- cifra = 6;
- }
- return rekurzija(x / 10) * 10 + cifra;
- }
- int main() {
- int n;
- scanf("%d", &n);
- printf("%d\n", rekurzija(n));
- return 0;
- }
- /*
- rekurzija(154) --> rekurzija(15) * 10 + 4 = 16 * 10 + 4 = 164
- rekurzija(15) --> rekurzija(1) * 10 + 6 = 1 * 10 + 6 = 16
- rekurzija(1) --> rekurzja(0) * 10 + 1 = 1
- rekurzija(0) --> 0
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement