您的位置:首页 > 其它

将一个英文语句以单词为单位逆序排放。

2017-08-17 12:48 441 查看
#include
#include

using namespace std;

int main()
{
string str;
getline(cin,str);
int len = str.length();
int pos = 0;
int i = 0;
for(i=len-1;i>=0;i--)
{
pos++;
if(' '==str[i])
{
cout<<str.substr(i+1,pos-1)<<' ';
pos = 0;
}
}
cout<<str.substr(0,pos)<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐