标签:程序 using include img src str png main 输出
题目描述:
给定一个英语句子,各个单词之间用空格分隔。要求编写程序,将所有单词倒序输出
输入示例:
Hello World Here I Come
输出示例:
Come I Here World Hello
1 #include <stack> 2 #include <string> 3 #include <iostream> 4 5 using namespace std; 6 7 int main(){ 8 stack<string> v; 9 string s; 10 while(cin >> s) v.push(s); 11 if(v.empty()) return 0; 12 cout << v.top(); 13 v.pop(); 14 while(!v.empty()){ 15 cout << " " << v.top(); 16 v.pop(); 17 } 18 return 0; 19 }
标签:程序 using include img src str png main 输出
原文地址:https://www.cnblogs.com/cxc1357/p/12219613.html