fork download
  1. #include <bits/stdc++.h>
  2. using namespace std ;
  3.  
  4. struct stdee {
  5. string name ;
  6. float marks ;
  7. };
  8.  
  9. bool compare (struct stdee s1 , struct stdee s2)
  10. {
  11. if(s1.marks > s2.marks)
  12. return 1;
  13. else
  14. return 0 ;
  15. }
  16. int main()
  17. {
  18. int n,i ;
  19. struct stdee student[100] ;
  20. cin >> n ;
  21.  
  22. for(i=0;i<n;i++)
  23. {
  24. cin >> student[i].name ;
  25. cin >> student[i].marks ;
  26. }
  27.  
  28.  
  29. sort(student,student+n,compare) ;
  30. for(i=0;i<n;i++)
  31. {
  32. //cout << student[i].marks<< " sort " ;
  33. }
  34.  
  35. cout << endl<<endl;
  36.  
  37. for(i=0;i<n;i++)
  38. {
  39. if(student[i].marks == student[1].marks)
  40. cout << student[i].name << " " << student[i].marks << endl ;
  41. }
  42.  
  43.  
  44. }
Success #stdin #stdout 0s 15248KB
stdin
6
a 37.21
b 37.21
c 37.2
d 41
e 39
f 39
stdout
e    39
f    39