Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <algorithm>
- #include <string>
- using namespace std;
- class Sound {
- int high, time;
- public:
- Sound() : high(0), time(0) {}
- Sound(int h, int t) : high(h), time(t) {}
- int getHigh() {
- return this->high;
- }
- int getTime() {
- return this->time;
- }
- void print_sound() {
- cout << "Note:" << this->high << " " <<" Duration:" << this->time << " sec" << endl;
- }
- };
- bool comporator(Sound left, Sound right) {
- return (left.getHigh() < right.getHigh());
- }
- int main() {
- vector <Sound> melody;
- int n;
- int h, t;
- cin >> n;
- for (int i = 0; i < n; i++) {
- cin >> h >> t;
- melody.push_back({ h, t });
- }
- cin >> h >> t;
- melody.push_back({ h, t });
- sort(melody.begin(), melody.end(), comporator);
- auto it = melody.begin();
- while (it != melody.end()) {
- it->print_sound();
- it++;
- }
- return 0;
- }
- 4
- 62 3
- 60 1
- 88 4
- 65 4
- 77 9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement