#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>

int main() {

std::string line_string;
while ( getline( std::cin, line_string ) ) {

    // Instead of `split`, read out of a std::istringstream:
    std::istringstream line_stream( line_string );
    std::string word;
    while ( line_stream >> word ) {

        // Use std::reverse instead of a loop:
        std::reverse( word.begin(), word.end() );

        // Always qualify with std:: instead of using namespace std;
        std::cout << word << ' ';
    }
    std::cout << '\n'; // prefer '\n' to std::endl unless you need a flush
}

}