1 solutions

  • 0
    @ 2026-11-14 11:34:11

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        string s;
        getline(cin,s);
    
        string space = " ";
        
        int l = 0,pos = 0;
        while(1){
            pos = s.find(space,pos);
            if (pos == string::npos){   //没有找到
                break;
            }
            
            for (int i = l;i<pos;i++)
                cout << s[i];
            cout << endl;
            l = pos = pos + space.size();
            
            space = space + " ";
            
        }
        
    
        for (int i = l;i<s.size();i++)
            cout << s[i];
        return 0;
    }
    
    • 1

    Information

    ID
    133
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    3
    Accepted
    2
    Uploaded By