Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(void) {
- FILE *in = fopen("bids.txt", "r");
- if (!in) {
- exit(1);
- }
- int max = 0;
- for (char buf[BUFSIZ]; fgets(buf, BUFSIZ, in);) {
- int bid;
- if (sscanf(buf, "%*s%d", &bid) == 1) {
- if (max < bid) {
- max = bid;
- }
- }
- }
- rewind(in);
- for (char buf[BUFSIZ]; fgets(buf, BUFSIZ, in);) {
- char name[BUFSIZ];
- int bid;
- if (sscanf(buf, "%s%d", name, &bid) == 2) {
- if (bid == max) {
- printf("%s\n", name);
- }
- }
- }
- fclose(in);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement