2 条题解

  • 0
    @ 2024-8-24 17:04:00

    string类属于STL,可以用reversebegin()end()函数 另外stringstream用在此处也很方便

    #include <iostream>
    #include <cstring>
    #include <algorithm>
    #include <sstream>
    
    using namespace std;
    
    string str, out, temp;
    
    int main()
    {
        getline(cin, str);
        
        stringstream ssin(str);
        
        while(ssin >> temp) {
            reverse(temp.begin(), temp.end());
            out += temp; out += ' ';
        }
        
        cout << out << endl;
        
        return 0;
    }
    

    信息

    ID
    134
    时间
    1000ms
    内存
    128MiB
    难度
    6
    标签
    (无)
    递交数
    116
    已通过
    34
    上传者