#include<iostream> #include<string> using namespace std; int main() {     string str;     getline(cin, str);     int point = str.size()-1;     int right = str.size();     int left;     bool flag = true;     unsigned int len = str.size();     for (int i = len - 1; i >= 0; i--)     {         if (str[i] != ' ')         {             flag = false;             point--;             continue;         }         if (!flag)         {             flag = true;             left = point;             point++;             while (point != right)             {                 cout << str[point];                 point++;             }             cout << " ";             point = left - 1;             right = left;         }         else         {             right = point;             point--;         }     }     point++;     if (point != right)     {         while (point != right)         {             cout << str[point];             point++;         }         cout << " ";     }     cout <<'\b';     return 0; } 后来想想可以这么做
点赞 1

相关推荐

感觉初筛都过不去,但是没挂我,我就先等着吧
投递华为技术有限公司等公司10个岗位
点赞 评论 收藏
分享
用微笑面对困难:这里面最强的是驾驶证了,可以入职美团大厂,然后直接开启黄马褂人生
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务