ITPub博客

首页 > > > 句子翻转,若干句子,此题未完成,想问问咋实现?

句子翻转,若干句子,此题未完成,想问问咋实现?

作者:mex 时间:2019-08-29 10:50:43 0 删除 编辑
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<sstream>
using namespace std;


int main()
{

vector<string> col;
string str1;
string word;
while(getline(cin,str1))
{
istringstream strin(str1);
while(strin>>word)
{
col.push_back(word);
}

}
vector<string>::iterator id;
id=col.end();
id--;
for(id;id>=col.begin();id--)
{
cout<<*id<<" ";

}
}

 

因为我这个是从最后一个往上读的,但是应该是按句读

现在是这样

a b c

d f g

out:

g f d c b a

但是要求是:

c b a

g f d 

麻烦给个思路


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3932/viewspace-3160500/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-07-09

  • 博文量
    193
  • 访问量
    1886