Вывести слова в предложении в обратном порядке — C++(Си)

#include <iostream>
#include <sstream>
#include <conio.h>
#include <string>
#include <stack>
 
using namespace std;
 
int main()
{
     string s;
     stack<string> st;
 
     getline(cin,s);
     stringstream in(s);
     while(in >> s)
         st.push(s);
     while(!st.empty())
     {
           cout << st.top() << ' ';
           st.pop();
     }
     getch();
}

Результат работы программы

Leave a Comment