Niloy007

Sakib's Problem 2

Dec 11th, 2020
328
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5.     int n;
  6.     scanf("%d", &n);
  7.     char name[50];
  8.     int score = 0;
  9.     char findName[50];
  10.     int gotAns = -1;
  11.     for (int i = 0; i < n; i++) {
  12.         fflush(stdin);
  13.         gets(name);
  14.         fflush(stdout);
  15.         scanf("%d", &score);
  16.         if(score > gotAns) {
  17.             strcpy(findName, name);
  18.             gotAns = score;
  19.         }
  20.     }
  21.     printf("%s\n%d\n", findName, gotAns);
  22. }
  23.  
RAW Paste Data