Advertisement
sellmmaahh

OR-Usmeni-Najveci Br U Stringu

Aug 13th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int NajveciBroj (char *s) {
  4.     int i, nb=0, max_broj=0;
  5.     while (*s!='\0') {
  6.             if (*s>='0' && *s<='9') {
  7.                     nb=nb*10+(*s-'0');
  8.             s++;
  9.             while (*s>='0' && *s<='9') {
  10.                     nb=nb*10+(*s-'0');
  11.             s++;
  12.             }
  13.             if (nb>max_broj) {
  14.                     max_broj=nb;
  15.             }
  16.             nb=0;
  17.             }
  18.             else {
  19.                 s++;
  20.             }
  21.     }
  22.     return max_broj;
  23. }
  24. int main () {
  25.     char s[]="123ab45CD678E9";
  26.     printf("%d", NajveciBroj(s));
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement