Advertisement
BorjanCrvenkov

Code zadaca 3 C

Feb 2nd, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  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. // vasiot kod pocnuva od ovde
  16. FILE *a=fopen("livce.txt","r");
  17. int uplata;
  18. fscanf(a,"%d",&uplata);
  19. float dobivka=uplata;
  20. char sifra[9],maxsifra[9];
  21. int tip,maxtip;
  22. float koef,maxkoef=0;
  23. while(fscanf(a,"%s %d %f",sifra,&tip,&koef)!=EOF){
  24. if(koef>maxkoef){
  25. maxtip=tip;
  26. maxkoef=koef;
  27. for(int i=0;i<=strlen(sifra);i++){
  28. maxsifra[i]=sifra[i];
  29. }
  30. }
  31. dobivka*=koef;
  32. }
  33. printf("%s %d %.2f\n%.2f",maxsifra,maxtip,maxkoef,dobivka);
  34. return 0;
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement