Advertisement
Josif_tepe

Untitled

Sep 30th, 2023
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <queue>
  2. #include <iostream>
  3. #include <vector>
  4. #include <cstring>
  5. #include <iostream>
  6. #include <set>
  7. #include <cstring>
  8. #include <stack>
  9. #include <algorithm>
  10. #include <map>
  11. #include <cmath>
  12. //#include <bits/stdc++.h>
  13. using namespace std;
  14. typedef long long ll;
  15. const int maxn = 3e5 + 10;
  16. const ll INF = 3e16 + 10;
  17.  
  18. struct student {
  19.     string name;
  20.     string surname;
  21.     int age;
  22.     double gpa;
  23.     string college;
  24.    
  25.     student() {} //empty constructor
  26.    
  27.     student(string _name, string _surname, int _age, double _gpa, string _college) {
  28.         name = _name;
  29.         surname = _surname;
  30.         age = _age;
  31.         gpa = _gpa;
  32.         college = _college;
  33.     }
  34.    
  35.     bool operator < (const student &tmp) const {
  36.         return age > tmp.age;
  37.     }
  38.    
  39. };
  40.  
  41. int main() {
  42.     ios_base::sync_with_stdio(false);
  43.     priority_queue<student> v;
  44.    
  45.     v.push(student("andrija", "mladenovik", 14, 5.0, "mig"));
  46.     v.push(student("petre", "petreski", 20, 5.0, "finki"));
  47.     v.push(student("alek", "aleksovski", 22, 6.0, "feit"));
  48.    
  49.    
  50.     while (!v.empty()) {
  51.         student s = v.top();
  52.         v.pop();
  53.         cout << s.name << " " << s.surname << " " << s.age << " " << s.gpa << " " << s.college << endl;
  54.     }
  55.     return 0;
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement