Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- float SrednjaVrijednost (char *s)
- { int suma=0, br_broj=0;
- int nb=0;
- while (*s!='\0')
- {
- if (*s>='0' && *s<='9') {
- while (*s>='0' && *s<='9') {
- nb=nb*10+(*s-'0');
- s++;
- }
- if (nb>0) {
- br_broj++;
- suma+=nb;
- }
- nb=0;
- }
- else s++;
- }
- return suma/br_broj;
- }
- int main () {
- char s[]="Fakultet je upisalo 225 redovnih, 83 vandredna i 4 studenta strana drzavljana.";
- printf("%.2f",SrednjaVrijednost(s));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement