// UVa 10361 - Automatic Poetry
#include <string>
#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
string dummy;
getline(cin, dummy);
for (; n; n--) {
string l1, l2;
getline(cin, l1);
getline(cin, l2);
int fst_less = l1.find_first_of("<");
int snd_less = l1.find_last_of("<");
int fst_greater = l1.find_first_of(">");
int snd_greater = l1.find_last_of(">");
string s1 = l1.substr(0, fst_less);
string s2 = l1.substr(fst_less + 1, fst_greater - fst_less - 1);
string s3 = l1.substr(fst_greater + 1, snd_less - fst_greater - 1);
string s4 = l1.substr(snd_less + 1, snd_greater - snd_less - 1);
string s5 = l1.substr(snd_greater + 1, l1.length() - snd_greater - 1);
int dots = l2.find_first_of("...");
string l3 = l2.replace(dots, dots + 3, s4 + s3 + s2 + s5);
cout << s1 << s2 << s3 << s4 << s5 << endl;
cout << l3 << endl;
}
return 0;
}
Monday, July 20, 2015
UVa 10361 - Automatic Poetry
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment