Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- int main()
- {
- FILE *fPointer;
- fPointer = fopen("text.txt","w");
- fprintf(fPointer,"Therefore some one more some left alas much knew one held uninspiring jeez that other and overpaid straight that outrageously that liberal abandoned affably.\n A some ouch considering far barring however ouch drew suave well glibly tapir ferret danced more chose as aboard much darn necessarily circa hey inconsiderate by.\n Irefully flailed that a obliquely sober that much naked until fish comfortably less prissily jeez a much rid lobster some pounded less led droll opposite near.");
- fclose(fPointer);
- if((fPointer=fopen("text.txt","r"))==NULL)
- {
- printf("Datotekata ne moze da se otvori.");
- return -1;
- }
- char ch,nova[1000],zborche[1000];
- int zborovi=0,flag=0,red=1,vkupnoR=0,brojac=0,max=0;
- while((ch=fgetc(fPointer))!=EOF)
- {
- nova[brojac]=ch;
- brojac++;
- if(isalpha(ch))
- {
- if(!flag)
- {
- flag=1;
- }
- }
- else if(flag)
- {
- flag=0;
- zborovi++;
- }
- if(ch == '\n')
- {
- printf("Red %d ima %d zborovi \n",red,zborovi);
- red++;
- vkupnoR+=zborovi;
- nova[brojac]='\0';
- if(zborovi>max)
- {
- max=zborovi;
- strcpy(zborche,nova);
- }
- brojac=0;
- zborovi=0;
- }
- }
- printf("Red %d ima %d zborovi \n",red,zborovi);
- vkupnoR+=zborovi;
- printf("\n Prosecniot broj na zborovi e %.2f ",(float)vkupnoR/red);
- for(int i=0;i<strlen(zborche);i++)
- {
- if(isupper(zborche[i]))
- {
- zborche[i] = tolower(zborche[i]);
- }
- else
- zborche[i] = toupper(zborche[i]);
- }
- printf("%s",zborche);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement