首页 > > > 句子翻转,若干句子,此题未完成,想问问咋实现?
#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/ ,如需转载,请注明出处,否则将追究法律责任。