#include <iostream>
#include <conio.h>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string s;
cin >> s;
reverse(s.begin(),s.end());
cout << s;
getch();
}
Результат работы программы

Следующий вариант
#include <iostream>
#include <conio.h>
#include <string>
#include <stack>
using namespace std;
int main()
{
string s;
stack<string> st;
while(cin >> s)
st.push(s);
while(!st.empty())
{
cout << st.top() << ' ';
st.pop();
}
getch();
}
Для окончания нажать ctrl+Z
Следующий вариант
С использованием файлов
#include <fstream>
#include <string>
#include <stack>
using namespace std;
ifstream cin("input.txt");
ofstream cout("output.txt");
int main()
{
string s;
stack<string> st;
while(cin >> s)
st.push(s);
while(!st.empty())
{
cout << st.top() << ' ';
st.pop();
}
}