Advertisement
AnaGocevska

Untitled

Jan 29th, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.08 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.  
  7.     char str[100];
  8.     int brZbor, brCifri, n, i;
  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.  
  18.     if(fout=fopen("izlez.txt", "w")==NULL)
  19.         {
  20.             printf("Ne postoi.");
  21.             exit(1);
  22.         }
  23.  
  24.     while(fgets(str, 100, fin)!=NULL)
  25.     {
  26.         i=0;
  27.         brZbor=0;
  28.         n=strlen(str);
  29.         while(i<n)
  30.         {
  31.  
  32.           if(isalnum(str[i]))
  33.           {
  34.               brCifri=0;
  35.               while(isalnum(str[i]))
  36.               {
  37.                   if(isdigit(str[i]))
  38.                      {
  39.                          brCifri++;
  40.                      }
  41.                   i++;
  42.               }
  43.               if(brCifri>2)
  44.               {
  45.                   brZbor++;
  46.               }
  47.           }
  48.           else
  49.           {
  50.               i++;
  51.           }
  52.         }
  53.     }
  54.     fprintf(fout, "%d\n%s\n", brZbor, str);
  55.         fclose(fin);
  56.         fclose(fout);
  57.         return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement