Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <stdio.h>
  5. #include <cmath>
  6. #include <iomanip>
  7.  
  8. using namespace std;
  9.  
  10. struct person{
  11. string name;
  12. string surname;
  13. double GPA;
  14. };
  15.  
  16.  
  17. bool operator< (person a, person b){
  18. if (a.GPA < b.GPA)
  19. return true;
  20. else
  21. return false;
  22. }
  23.  
  24. double eps = 0.000001;
  25.  
  26. int main(){
  27. int n;
  28. cin >> n;
  29. vector<person> v(n);
  30. for (int i = 0; i < n; i++){
  31. cin >> v[i].name >> v[i].surname >> v[i].GPA;
  32. }
  33.  
  34. sort(v.begin(), v.end());
  35.  
  36.  
  37. for (int i = 0; i < n; i++){
  38. cout << v[i].GPA << " " << v[i].name << " " << v[i].surname << endl;
  39. }
  40. return 0;
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement