-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10.12.cpp
More file actions
38 lines (35 loc) · 803 Bytes
/
10.12.cpp
File metadata and controls
38 lines (35 loc) · 803 Bytes
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
#include "Sales_data.h"
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <sstream>
using std::istringstream;
using std::sort;
using std::cin;
using std::vector;
using std::string;
using std::cout;
using std::endl;
using std::getline;
bool compareIsbn(const Sales_data &elem1, const Sales_data &elem2) {
return elem1.isbn() < elem2.isbn();
}
int main() {
vector<Sales_data> items;
string line;
while (getline(cin, line)) {
string bookNo;
unsigned units_sold;
double price;
istringstream stream(line);
stream >> bookNo >> units_sold >> price;
items.emplace(items.end(), bookNo, units_sold, price);
}
cout << '\n';
sort(items.begin(), items.end(), compareIsbn);
for (const Sales_data &elem : items) {
print(cout, elem) << '\n';
}
return 0;
}