首页 新闻 赞助 找找看

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

0
悬赏园豆:5 [已解决问题] 解决于 2016-11-27 19:21

#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 

麻烦给个思路

c++
邗影的主页 邗影 | 初学一级 | 园豆:73
提问于:2016-09-23 21:08
< >
分享
最佳答案
0

思路:在做翻转操作前,先判断句子中回车符的位置,然后从该位置把句子分成两句,一句一句翻转

收获园豆:5
Dmego | 菜鸟二级 |园豆:246 | 2016-11-11 11:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册