-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ2870.cpp
More file actions
69 lines (61 loc) · 1.63 KB
/
BOJ2870.cpp
File metadata and controls
69 lines (61 loc) · 1.63 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <limits.h>
#include <string.h>
#include <string>
#include <sstream>
#define MAX 105
#define INF 2123456789
using namespace std;
typedef long long ll;
int n;
char str[205];
vector<vector<char>> v;
int main() {
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%s", str);
queue<char> tmp;
for(int j=0;j<strlen(str);j++)
{
// 0~9 사이의 값인 경우
if('0'<=str[j]&&str[j]<='9')
tmp.push(str[j]);
// 0~9 사이의 값이아니거나 마지막이고 큐의 원소가 한개이상인 경우
if((!('0'<=str[j]&&str[j]<='9')||j==(strlen(str)-1))&&tmp.size()!=0)
{
// 앞에 나온 0을 모두 제거하여준다.
while(!tmp.empty()&&tmp.front()=='0')
tmp.pop();
vector<char> vv;
while(!tmp.empty()) {
vv.push_back(tmp.front());
tmp.pop();
}
// 0인 경우
if(vv.size()==0)
vv.push_back('0');
v.push_back(vv);
}
}
}
// 문자열 비교한다.
sort(v.begin(),v.end());
// 문자열 길이순으로 출력해준다.
for(int k=1;k<=100;k++)
{
for(int i=0;i<v.size();i++)
{
if(v[i].size()==k) {
for (int j = 0; j < v[i].size(); j++)
printf("%c", v[i][j]);
printf("\n");
}
}
}
return 0;
}