Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int length (char *s) {
- int d=0;
- while (*(s++)!='\0') d++;
- return d;
- }
- int JeLiBroj (char c) {
- if (c>='0' && c<='9') return 1;
- return 0;
- }
- int MaxBroj (char *s) {
- int duzina=length(s), i, nb=0, max_broj=0;
- for (i=0; i<duzina; i++) {
- if (JeLiBroj(s[i])) {
- nb=nb*10+s[i]-'0';
- i++;
- while (JeLiBroj(s[i])) {
- nb=nb*10+s[i]-'0';
- i++;
- }
- }
- if (nb>max_broj)
- max_broj=nb;
- else nb=0;
- }
- return max_broj;
- }
- int main () {
- char s[]="Selma234 je bila 5678 ovdje 123.";
- printf("Najveci broj u recenici: %d", MaxBroj(s));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement