Advertisement
sellmmaahh

Zad3

Aug 12th, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int okreni(int n)
  4. {
  5.     int broj = 0;
  6.    
  7.     while(n > 0)
  8.     {
  9.         broj = broj * 10 + n % 10;
  10.         n = n / 10;
  11.     }
  12.    
  13.     return broj;
  14. }
  15.  
  16. int filter(char* string)
  17. {
  18.     int broj = 0;
  19.    
  20.     while(*string != 0)
  21.     {
  22.         if (*string >= '0' && *string <= '9')
  23.         {
  24.             broj = broj * 10 + (*string - '0');
  25.         }
  26.        
  27.         string++;
  28.     }
  29.    
  30.     return okreni(broj);
  31. }
  32.  
  33. int main()
  34. {
  35.     char string[] = "hrk45ljus21";
  36.    
  37.     printf("%d", filter(string));
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement