#include <iostream>
#include <string>
using namespace std;

string swapBits(string s) {
    int n = s.length();
    for (int i = 0; i < n; i += 2) {
        swap(s[i], s[i+1]);
    }
    return s;
}

int main() {
    int C;
    cin >> C;
    for (int i = 0; i < C; i++) {
        string s;
        cin >> s;
        cout << swapBits(s) << endl;
    }
    return 0;
}
C++ 编程实现字符串奇偶位互换

原文地址: https://www.cveoy.top/t/topic/i7Iq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录