Advertisement
Guest User

1.zad feb2018

a guest
Jan 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7.     int x;
  8.     int tmp_x;
  9.     int cifra;
  10.     int zbir;
  11.     int br_cifara = 0;
  12.        
  13.  
  14.     while(scanf("%d", &x) == 1)
  15.     {
  16.         tmp_x = abs(x);
  17.  
  18.         br_cifara = (int)(log10(tmp_x) + 1);
  19.         zbir = 0;
  20.        
  21.         while(tmp_x != 0)
  22.         {
  23.             cifra = tmp_x % 10;
  24.             zbir = zbir + cifra;
  25.             tmp_x = tmp_x / 10;
  26.         }              
  27.        
  28.         if((br_cifara % 2 == 0) || (zbir % 2 == 0))
  29.         {
  30.                 printf("%d ", x);
  31.         }
  32.     }
  33.  
  34.     printf("\n");
  35.  
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement