Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- typedef struct player {
- char name[31];
- int ftM, ftA, twoM, twoA, thrM, thrA, pts;
- }Player;
- int main(void) {
- FILE *file = fopen("stats.txt", "r");
- if (!file) {
- perror(NULL);
- exit(1);
- }
- Player p, max;
- max.pts = -1;
- 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) {
- //POGLEDAJ OVO !!!!!!
- p.pts = p.ftM + p.twoM * 2 + p.thrM * 3;
- if (p.pts > max.pts) {
- max = p;
- }
- }
- if (max.pts != -1) {
- printf("%s %d/%d %d\n", max.name, (max.twoM + max.thrM), (max.twoA + max.thrA), max.pts);
- }
- fclose(file);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement