桂林电子科技大学第三届ACM程序设计竞赛 H题

链接:https://ac.nowcoder.com/acm/contest/558/H
来源:牛客网

小猫在研究字符串。
小猫在研究奇数的性质。
给定一个字符串S,请你输出将其奇数位的字符提出来以后得到的字符串。
水题

#include <bits/stdc++.h>
using namespace std;
int main() {
    int T;
    cin >> T;
    while (T--) {
        string str;
        cin >> str;
        for (int i = 0; i < str.size(); i += 2) {
            cout << str[i];
        }
        cout << endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_37520038/article/details/89341829