forked from ndb796/python-for-coding-test
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2.cpp
35 lines (28 loc) Β· 789 Bytes
/
2.cpp
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
#include <bits/stdc++.h>
using namespace std;
string str;
vector<char> result;
int value = 0;
int main(void) {
cin >> str;
// λ¬Έμλ₯Ό νλμ© νμΈνλ©°
for (int i = 0; i < str.size(); i++) {
// μνλ²³μΈ κ²½μ° κ²°κ³Ό 리μ€νΈμ μ½μ
if (isalpha(str[i])) {
result.push_back(str[i]);
}
// μ«μλ λ°λ‘ λνκΈ°
else {
value += str[i] - '0';
}
}
// μνλ²³μ μ€λ¦μ°¨μμΌλ‘ μ λ ¬
sort(result.begin(), result.end());
// μνλ²³μ μ°¨λ‘λλ‘ μΆλ ₯
for (int i = 0; i < result.size(); i++) {
cout << result[i];
}
// μ«μκ° νλλΌλ μ‘΄μ¬νλ κ²½μ° κ°μ₯ λ€μ μΆλ ₯
if (value != 0) cout << value;
cout << '\n';
}