Advertisement
samrina_sarkar_7

Prbl 3

Jun 21st, 2020
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6.     int n,i, j, k;
  7.      printf(" Number of restaurants :") ;
  8.      scanf("%d", & n) ;
  9.  
  10.     char str[20],str1[20]
  11.     scanf("%s %d",str,&j);
  12.  
  13.     for(i=0;i<n;i++)
  14.     {
  15.         scanf("%s %d",str1,&k);
  16.         if(j<k)
  17.         {
  18.             j=k;
  19.             strcpy(str, str1);
  20.         }
  21.             else if(j==k && strcmp(str, str1)>0)
  22.             {
  23.                 j=k;
  24.                  strcpy(str, str1);
  25.             }
  26.  
  27.     }
  28.     printf("%s",str);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement