# 파싱
파싱은 정말 문제 잘 안 읽어서 실수하는 경우도 많고.
이 부분을 실수 했다.
while(tmp.front()=='0') -> while(!tmp.empty()&&tmp.front()=='0')
#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;
}'IT > BOJ' 카테고리의 다른 글
| 백준(BOJ) 13458 로봇 청소기 ** (0) | 2019.03.20 |
|---|---|
| 백준(BOJ) 13458 시험 감독 * (0) | 2019.03.18 |
| 백준(BOJ) 2667 단지번호붙이기 * (0) | 2019.03.14 |
| 백준(BOJ) 2665 미로만들기 * (0) | 2019.03.13 |
| 백준(BOJ) 16189 Repetitive Palindrome * (0) | 2018.10.07 |