Advertisement
Guest User

Alekkkk

a guest
May 24th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 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 *f = fopen("livce.txt", "r");
  17.     int tip, maxTip, uplata;
  18.     char sifra[15], maxSifra[15];
  19.     float koef, maxKoef = 0, total;
  20.    
  21.     fscanf(f, "%d", &uplata);
  22.     total = uplata;
  23.    
  24.     while ((fscanf(f,"%s %d %f", &sifra, &tip, &koef)) != EOF){
  25.         total *= koef;
  26.        
  27.         if (koef > maxKoef){
  28.             maxKoef = koef;
  29.             maxTip = tip;
  30.             strcpy(maxSifra, sifra);
  31.         }
  32.        
  33.     }
  34.    printf("%s %d %.2f\n", maxSifra, maxTip, maxKoef);
  35.    printf("%.2f", total);
  36.    
  37.    
  38.     fclose(f);
  39.     return 0;    
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement