Advertisement
Guest User

jocke nba igraci

a guest
May 23rd, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. typedef struct player {
  5.  
  6.     char name[31];
  7.     int ftM, ftA, twoM, twoA, thrM, thrA, pts;
  8.  
  9. }Player;
  10.  
  11. int main(void) {
  12.  
  13.     FILE *file = fopen("stats.txt", "r");
  14.     if (!file) {
  15.         perror(NULL);
  16.         exit(1);
  17.     }
  18.  
  19.     Player p, max;
  20.     max.pts = -1;
  21.  
  22.     while ((fscanf(file, "%[^;];%d/%d %d/%d %d/%d\n", p.name, &p.ftA, &p.ftM, &p.twoA, &p.twoM, &p.thrA, &p.thrM)) == 7) {
  23.  
  24.         //POGLEDAJ OVO !!!!!!
  25.         p.pts = p.ftM + p.twoM * 2 + p.thrM * 3;
  26.         if (p.pts > max.pts) {
  27.             max = p;
  28.         }
  29.     }
  30.  
  31.     if (max.pts != -1) {
  32.         printf("%s %d/%d %d\n", max.name, (max.twoM + max.thrM), (max.twoA + max.thrA), max.pts);
  33.     }
  34.  
  35.     fclose(file);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement