文章

3

粉丝

0

获赞

1

访问

48

头像
字符移动 题解:利用两个char向量来完成
P1012 贵州大学机试题
发布于2025年5月7日 14:11
阅读数 12

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

int main(){
    string str;
    //用两个向量分别来接收数字和非数字 
    vector<char> a,b;
    cin>>str;
    for(auto x:str){
        if(isdigit(x))    a.push_back(x);
        else    b.push_back(x);
    }
    //再将两个向量拼接在一起 
    b.insert(b.end(),a.begin(),a.end());
    for(auto x:b){
        cout<<x;
    }
    return 0;
}

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发