#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
string str1, str2, str3, str4, str5;
string str, Str;
void destruction()
{
str1 = str2 = str3 = str4 = str5 = "";
int num = 0;
for (int i = 0; i < str.length(); i++)
{
if (str[i] == '<' || str[i] == '>')
{
num++;
}
else
{
if (num == 0)
{
str1 += str[i];
}
else if (num == 1)
{
str2 += str[i];
}
else if (num == 2)
{
str3 += str[i];
}
else if (num == 3)
{
str4 += str[i];
}
else if (num == 4)
{
str5 += str[i];
}
}
}
}
void solve()
{
cout << str1 << str2 << str3 << str4 << str5 << endl;
for (int i = 0; i < Str.length() - 3; i++)
{
cout << Str[i];
}
cout << str4 << str3 << str2 << str5 << endl;
}
void input()
{
int t;
char ch;
scanf("%d", &t); //注意
getchar();
while (t--)
{
getline(cin, str);
getline(cin, Str);
destruction();
solve();
}
}
int main()
{
input();
return 0;
}
ACM-uva10361
最新推荐文章于 2015-08-02 12:03:01 发布