Advertisement
LegoDrifter

Datoteki 9

Jun 17th, 2020
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. int proverka(char *c)
  6. {
  7.     int i,j,vk=0;
  8.     for(i = 0;i<strlen(c);i++)
  9.     {
  10.         vk=0;
  11.         for(j=i;j<strlen(c);j++)
  12.         {
  13.             if(toupper(*(c+i))==toupper(*(c+j)))
  14.                 vk++;
  15.  
  16.         }
  17.         if(vk>2)
  18.             return 1;
  19.     }
  20.     return 0;
  21. }
  22.  
  23.  
  24.  
  25. int main()
  26. {
  27.     FILE *fPointer;
  28.     fPointer = fopen("test.txt","w");
  29.     fprintf(fPointer,"Ova e testt za da vidime sedum osum devet deset.");
  30.     fclose(fPointer);
  31.  
  32.     FILE *fPointer1;
  33.     fPointer1 = fopen("test.txt","r");
  34.     char ch;
  35.     int brojac=0;
  36.     char zbor[100];
  37.     int vkupno=0;
  38.     int vo_zbor=0;
  39.  
  40.     while ((ch=getc(fPointer1))!=EOF)
  41. {
  42.     if (isalpha(ch))
  43.     {
  44.         if (!vo_zbor)
  45.         {
  46.             vo_zbor=1;
  47.         }
  48.             zbor[brojac]=ch;
  49.             brojac++;
  50.     }
  51.     else
  52.     if (vo_zbor)
  53.     {
  54.         vo_zbor=0;
  55.         zbor[brojac]='\0';
  56.         if (proverka(zbor))
  57.     {
  58.         puts(zbor);
  59.         vkupno++;
  60.     }
  61.         zbor[0]='\0';
  62.         brojac=0;
  63.     }
  64.     }
  65.     if (vo_zbor)
  66.     {
  67.         zbor[brojac]='\0';
  68.     if (proverka(zbor))
  69.     {
  70.         puts(zbor);
  71.         vkupno++;
  72.     }
  73.     }
  74.     printf("Vkupno %d zborovi.\n",vkupno);
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement