forked from CodersSquad/tmp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (38 loc) · 1.13 KB
/
main.cpp
File metadata and controls
49 lines (38 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <functional>
#include <iostream>
#include <queue>
#include <string_view>
#include <string>
#include <sstream>
#include <vector>
#include "person.h"
#include "utils.h"
using namespace utils;
using namespace std;
void init_people_queue(priority_queue<Person> *people_queue, int n) {
for (int i = 0; i < n; i++) {
int age = generateRandomInt(1,100);
ostringstream oss;
oss << 2025-age << "-" << generateRandomInt(1,12) << "-" << generateRandomInt(1,30);
string birthdate = oss.str();
Person new_person(generateRandomName(10), age, birthdate);
people_queue->push(new_person);
}
}
int main() {
std::priority_queue<Person> people_by_age;
init_people_queue(&people_by_age, 10);
while (!people_by_age.empty()) {
Person p = people_by_age.top();
p.displayInfo();
people_by_age.pop();
}
std::priority_queue<Person> people_by_birthday; // or maybe here
// you need something here
init_people_queue(&people_by_birthday, 10);
while (!people_by_birthday.empty()) {
Person p = people_by_birthday.top();
p.displayInfo();
people_by_birthday.pop();
}
}