题解 | #分离#

分离

https://ac.nowcoder.com/acm/problem/23973

将奇数位置取出来即可:

while i<s.size()
	str+=s[i]
    i+=2

c++:

#include <bits/stdc++.h>
using namespace std;
int main(){
    int T=0;
    cin>>T;
    while(T!=0){
        string str;
        cin>>str;
        vector<char> tmp;
        for(int i=0;i<str.size();i+=2){
            tmp.push_back(str.at(i));
        }
        string res(tmp.begin(),tmp.end());
        cout<<res<<endl;
        T--;
    }
}
全部评论

相关推荐

01-15 19:59
中山大学 C++
牛客60887332...:你这是人写出来的? 本科标到硕士后面 留那么多空给 hr 填?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务