-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMath_Homework_bj.cpp
More file actions
57 lines (51 loc) · 980 Bytes
/
Copy pathMath_Homework_bj.cpp
File metadata and controls
57 lines (51 loc) · 980 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// baekjoon 2870
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N, sum;
vector<string>report;
string save;
string sentence_line;
bool comp(string str1, string str2) {
if (str1.length() < str2.length()) {
return true;
}
else if (str1.length() == str2.length()) {
if (str1 < str2)
return true;
else
return false;
}
else
return false;
}
int main() {
cin >> N;
for (int i{ 0 }; i < N; i++) {
cin >> sentence_line;
save = "";
for (int j{ 0 }; j < sentence_line.length(); j++) {
if (sentence_line[j] >= '0' && sentence_line[j] <= '9') {
if (save == "0") {
save = "";
}
save += sentence_line[j];
}
else {
if (save.length() > 0) {
report.push_back(save);
save = "";
}
}
}
if (save.size() > 0) {
report.push_back(save);
save = "";
}
}
sort(report.begin(), report.end(), comp);
for (int i{ 0 }; i < report.size(); i++) {
cout << report[i] << endl;
}
}