Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // uloha-5-5.c -- Tyzden 5 - Uloha 5
- // Michal Kovacik, 21.10.2013 08:06:41
- #include <stdio.h>
- int main()
- {
- FILE *f1, *f2;
- int dlzkaf1=0, dlzkaf2=0, mindlzka, znaky=0;
- if ((f1=fopen("PRVY.TXT", "r"))==NULL || (f2=fopen("DRUHY.TXT", "r"))==NULL)
- {
- printf("Subor sa nepodarilo otvorit\n");
- return 0;
- }
- while(getc(f1)!=EOF)
- dlzkaf1++;
- while(getc(f2)!=EOF)
- dlzkaf2++;
- if(dlzkaf1<=dlzkaf2)
- mindlzka=dlzkaf1;
- else
- mindlzka=dlzkaf2;
- rewind(f1);
- rewind(f2);
- for(; mindlzka>=1; mindlzka--)
- ((getc(f1))!=(getc(f2)))? znaky++:0;
- if((dlzkaf1-dlzkaf2==0) && znaky==0)
- printf("Subory su identicke\n");
- else
- {
- printf("Pocet roznych znakov: %d\n", znaky);
- printf("Jeden zo suborov je dlhsi o %d znakov", (dlzkaf1<=dlzkaf2)? (dlzkaf2-dlzkaf1):(dlzkaf1-dlzkaf2));
- }
- fclose(f1);
- fclose(f2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement