1 条题解

  • 1
    @ 2024-12-3 13:23:04

    双指针法

    #include<bits/stdc++.h> using namespace std; int main() { string str; getline(cin,str); str+=' '; int begin=0,end=0; while(begin<=str.size()-1) { while(str[end]!=' ') { end++; } for(int i=end-1;i>=begin;i--) { cout<<str[i]; } while(str[end]==' ') { cout<<' '; end++; } begin=end; } return 0; }

    
    

    信息

    ID
    182
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    5
    已通过
    3
    上传者