Advertisement
sellmmaahh

OR-skripta Adijata-zad 38-Vrati Najveci Br iz Stringa

Aug 26th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int length (char *s) {
  6.     int duzina=0;
  7.     while (*(s++)!='\0') duzina++;
  8.     return duzina;
  9. }
  10. int JeLiBroj (char c) {
  11.     if (c>='0' && c<='9') return 1;
  12.     return 0;
  13. }
  14. int VratiNajveci (char *s) {
  15.     int maxi=0, nb=0, i, duz=length(s);
  16.     for (i=0; i<duz; i++) {
  17.             if (JeLiBroj(s[i])) {
  18.                     nb=nb*10+(s[i]-'0');
  19.                i++;
  20.                while (JeLiBroj(s[i])) {
  21.                     nb=nb*10+(s[i]-'0');
  22.                      i++;
  23.                }
  24.                if (nb>maxi)  maxi=nb;
  25.               nb=0;
  26.                }
  27.     }
  28.     return maxi;
  29. }
  30. int main () {
  31.     printf("%d",VratiNajveci("Selma 123 je bila 45 ovdje 345"));
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement