iSharp
https://www.acmicpc.net/problem/3568
<문제>
<코드>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
string a,b,c,d,e,temp,ans1,ans2;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
getline(cin, a);
for (int i = 0; i < a.size(); i++)
{
if (a[i] == ' ')
{
b = a.substr(0, i);
c = a.substr(i+1);
break;
}
}
int cnt = 0;
for (int i = 0; i < c.size(); i++)
{
if (c[i] == ',' || c[i] == ';')
{
if (cnt == 0)
cnt++;
else
temp.erase(0,1);
for (int j = 0; j < temp.size(); j++)
{
if (isalpha(temp[j]))
ans1.push_back(temp[j]);
else
ans2.push_back(temp[j]);
}
reverse(ans2.begin(), ans2.end());
for (int k = 0; k < ans2.size(); k++)
{
if (ans2[k] == '[')
ans2[k] = ']';
else if(ans2[k] == ']')
ans2[k] = '[';
}
cout << b << ans2 << ' ' << ans1<<';'<<endl;
temp.clear(); ans1.clear(); ans2.clear();
}
else
temp.push_back(c[i]);
}
}
'Algorithm > 시뮬레이션' 카테고리의 다른 글
[백준][15685번][시뮬레이션] 드래곤 커브 (1) | 2019.05.08 |
---|---|
[백준][14503번][시뮬레이션] 로봇 청소기 (0) | 2019.05.04 |