#include <iostream>
using namespace std;
void reverseWord(char *start, char *end) {
while (start < end) {
char temp = *start;
*start = *end;
*end = temp;
start++;
end--;
}
}
int main() {
char input[501]; // 输入字符串,长度不超过500,加1用于终止符
cin.getline(input, 501); // 读取一行输入
char *wordStart = input; // 指向单词的起始位置
char *current = input; // 当前遍历的字符指针
while (*current != '\0') {
if (*current == ' ') { // 遇到空格,翻转前面的单词
reverseWord(wordStart, current - 1);
wordStart = current + 1; // 更新单词起始位置
}
current++;
}
// 翻转最后一个单词(如果句子不以空格结尾)
reverseWord(wordStart, current - 1);
cout << input << endl; // 输出结果
return 0;
}