文章

61

粉丝

98

获赞

17

访问

15.5k

头像
字符分类 题解:c++实现
P1016 兰州大学/贵州大学机试题
发布于2024年3月9日 14:43
阅读数 106

#include<bits/stdc++.h>
using namespace std;

int main(){
    string s;
    string number;
    string alph;
    string other;
    cin >> s;
    int len = s.length();
    for(int i = 0; i < len; i++){
        if(s[i] <= 'Z' && s[i] >= 'A')
            alph.push_back(s[i]);
        else if(s[i] <= 'z' && s[i] >= 'a')
            alph.push_back(s[i]);
        else if(s[i] <= '9' && s[i] >= '0')
            number.push_back(s[i]);
        else
            other.push_back(s[i]);
    }
    cout << alph << endl;
    cout << number << endl;
    cout << other << endl;
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发