Advertisement
Josif_tepe

Untitled

Nov 5th, 2023
691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 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) {
  7.     if(broj == 0) {
  8.         return 0;
  9.     }
  10.     return rek(broj / 10) + 1;
  11. }
  12. int main(int argc, const char * argv[]) {
  13.     int n;
  14.     scanf("%d", &n);
  15.     if(rek(n) % 2 == 0) {
  16.         printf("1\n");
  17.     }
  18.     else {
  19.         printf("0\n");
  20.     }
  21.    
  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