#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
int ch;
int n;
#ifndef ONLINE_JUDGE
freopen("d:\\OJ\\uva_in.txt", "r", stdin);
#endif // ONLINE_JUDGE
while (cin >> n && n) {
string s;
char prev = -1;
//cout << "n:" << n <<endl;
for (int i = 0; i < n && (ch = cin.get()) != EOF;) {
if (isalpha(ch)) {
i++;
s += (char)ch;
prev = ch;
} else if (ch == ' ') {
if (prev != ' ') {
if (s.length() > 0) {
reverse(s.begin(), s.end());
cout << s;
s.clear();
}
cout << (char)ch;
}
i++;
prev = ch;
}
}
if (s.length() > 0) {
reverse(s.begin(), s.end());
cout << s;
}
cout << endl;
}
return 0;
}
题目1525:子串逆序打印
最新推荐文章于 2021-07-18 19:08:53 发布