Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. // ne menuvaj ovde
  4. void wf() {
  5. FILE *f = fopen("livce.txt", "w");
  6. char c;
  7. while((c = getchar()) != '#') {
  8. fputc(c, f);
  9. }
  10. fclose(f);
  11. }
  12.  
  13. int main() {
  14. wf();
  15. FILE *dat;
  16. float uplata;
  17. char sifra[10];
  18. char print[10];
  19. float max=-9999999;
  20. char c;
  21. int tip;
  22. float koeficient;
  23. float zacuvankoeficient;
  24. int zacuvantip;
  25. // vasiot kod pocnuva od ovde
  26. if ((dat = fopen("livce.txt", "r")) == NULL) {
  27. printf("Datotekata livce.txt ne se otvora!\n");
  28. return -1;
  29. }
  30. fscanf(dat,"%f", &uplata);
  31. while((fscanf(dat, "%s%d%f", sifra, &tip, &koeficient)) != EOF)
  32. {
  33. uplata*=koeficient;
  34. if(koeficient>max)
  35. {
  36. max=koeficient;
  37. strcpy(print,sifra);
  38. zacuvankoeficient=koeficient;
  39. zacuvantip=tip;
  40. }
  41. }
  42. printf("%s %d %.2f\n%.2f", print, zacuvantip, zacuvankoeficient, uplata);
  43. return 0;
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement