Advertisement
AnaGocevska

Untitled

Jan 30th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.24 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.     int red=0, n, i, brZbor, prosek, counter=0;
  7.     char str[100];
  8.     int niza[100];
  9.     FILE *fin;
  10.     FILE *fout;
  11.  
  12.     if((fin=fopen("vlez.txt","r"))==NULL)
  13.        {
  14.            printf("Ne postoi.");
  15.            exit(1);
  16.        }
  17.     if((fout=fopen("izlez.txt", "w"))==NULL)
  18.         {
  19.             printf("Ne postoi.");
  20.             exit(1);
  21.         }
  22.  
  23.         for(i=0; i<100; i++)
  24.         {
  25.                 niza[i]=0;
  26.         }
  27.  
  28.     while(fgets(str, 80, fin)!=NULL)
  29.     {
  30.         n=strlen(str);
  31.         i=0;
  32.         while(i<n)
  33.         {
  34.             if(isalnum(str[i]))
  35.             {
  36.                 brZbor=0;
  37.                 while(i<n && isalnum(str[i]))
  38.                 {
  39.                     i++;
  40.                 }
  41.                 brZbor++;
  42.             }
  43.             else
  44.             {
  45.                 i++;
  46.             }
  47.         }
  48.         niza[red]=brZbor;
  49.         red++;
  50.     }
  51.         prosek=brZbor/red;
  52.  
  53.         for(i=0; i<red; i++)
  54.         {
  55.             if(niza[i]<prosek)
  56.             {
  57.                 counter++;
  58.             }
  59.         }
  60.         fprintf(fout, "%d", counter);
  61.         fclose(fin);
  62.         fclose(fout);
  63.         return 0;
  64.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement