#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

相关推荐

不愿透露姓名的神秘牛友
11-24 20:55
阿里国际 Java工程师 2.7k*16.0
程序员猪皮:没有超过3k的,不太好选。春招再看看
点赞 评论 收藏
分享
10-07 23:57
已编辑
电子科技大学 Java
八街九陌:博士?客户端?开发?啊?
点赞 评论 收藏
分享
牛客网
牛客企业服务