C++读取屏幕输入

来源:互联网 发布:薛之谦淘宝店地址 编辑:程序博客网 时间:2024/04/30 21:31

1.C++读取屏幕一行的多个字符串,字符串用空格隔开


#include <iostream>#include <string>#include <stack>using namespace std;int main(){    stack<string> str;    cout<<"Please enter some strings separated by space! Q to quit!"<<endl;    string temp;    cin>>temp;    while(temp!="Q")    {        str.push(temp);        cin>>temp;    }    while(!str.empty())    {        cout<<str.top()<<" ";        str.pop();    }    cout<<endl;    return 0;}



测试结果:















0 0
原创粉丝点击