Advertisement
Josif_tepe

Untitled

Nov 5th, 2023
770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6. int rek(int broj, int broj_na_cifri) {
  7.     if(broj == 0) {
  8.         if(broj_na_cifri % 2 == 0) {
  9.             return 1;
  10.         }
  11.         else {
  12.             return 0;
  13.         }
  14.     }
  15.     return rek(broj / 10, broj_na_cifri + 1);
  16. }
  17. int main(int argc, const char * argv[]) {
  18.     int n;
  19.     scanf("%d", &n);
  20.    
  21.     printf("%d\n", rek(n, 0));
  22.     return 0;
  23. }
  24. /*
  25.  rek(12345, 0) = rek(1234, 1) = 0
  26.  rek(1234, 1) = rek(123, 2) = 0
  27.  rek(123, 2) = rek(12, 3) = 0
  28.  rek(12, 3) = rek(1, 4) = 0
  29.  rek(1, 4) = rek(0, 5) = 0
  30.  rek(0, 5) = 0
  31.  */
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement