1 条题解

  • 1
    @ 2026-1-4 12:58:24

    简单???

    #include <iostream>
    #include <string>
    using namespace std;
     
    int main() {
        string input;
        getline(cin, input);  // 读取整行输入 
        
        size_t comma_pos = input.find(',');   // 查找逗号位置 
        
        if (comma_pos != string::npos) {
            // 提取第一个单词(逗号前)
            string first_word = input.substr(0,  comma_pos);
            // 提取第二个单词(逗号后)
            string second_word = input.substr(comma_pos  + 1);
            // 输出交换后的结果 
            cout << second_word << "," << first_word << endl;
        } else {
            // 如果没有找到逗号,原样输出 
            cout << input << endl;
        }
        
        return 0;
    }
    
    • 1

    信息

    ID
    117
    时间
    1000ms
    内存
    16MiB
    难度
    4
    标签
    (无)
    递交数
    475
    已通过
    228
    上传者