Advertisement
LegoDrifter

Untitled

Jan 21st, 2021
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6. int main()
  7. {
  8. FILE *fPointer;
  9. fPointer = fopen("text.txt","w");
  10. 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.");
  11. fclose(fPointer);
  12.  
  13. if((fPointer=fopen("text.txt","r"))==NULL)
  14. {
  15. printf("Datotekata ne moze da se otvori.");
  16. return -1;
  17. }
  18.  
  19. char ch,nova[1000],zborche[1000];
  20. int zborovi=0,flag=0,red=1,vkupnoR=0,brojac=0,max=0;
  21. while((ch=fgetc(fPointer))!=EOF)
  22. {
  23. nova[brojac]=ch;
  24. brojac++;
  25. if(isalpha(ch))
  26. {
  27. if(!flag)
  28. {
  29. flag=1;
  30. }
  31. }
  32. else if(flag)
  33. {
  34. flag=0;
  35. zborovi++;
  36. }
  37. if(ch == '\n')
  38. {
  39. printf("Red %d ima %d zborovi \n",red,zborovi);
  40. red++;
  41. vkupnoR+=zborovi;
  42. nova[brojac]='\0';
  43. if(zborovi>max)
  44. {
  45. max=zborovi;
  46. strcpy(zborche,nova);
  47. }
  48. brojac=0;
  49. zborovi=0;
  50. }
  51. }
  52. printf("Red %d ima %d zborovi \n",red,zborovi);
  53. vkupnoR+=zborovi;
  54. printf("\n Prosecniot broj na zborovi e %.2f ",(float)vkupnoR/red);
  55. for(int i=0;i<strlen(zborche);i++)
  56. {
  57. if(isupper(zborche[i]))
  58. {
  59. zborche[i] = tolower(zborche[i]);
  60. }
  61. else
  62. zborche[i] = toupper(zborche[i]);
  63. }
  64. printf("%s",zborche);
  65.  
  66.  
  67. return 0;
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement