文章

62

粉丝

66

获赞

62

访问

4.6k

头像
字符分类 题解:
P1016 兰州大学/贵州大学机试题
发布于2024年4月20日 16:06
阅读数 51

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

int main()
{
    string str;
    
    getline(cin, str);
    
    string num, c, others;
    
    for(int i = 0; i < str.size(); i ++)
    {
        if(str[i] >= '0' && str[i] <= '9')
            num += str[i];
        else if(str[i] >= 'A' && str[i] <= 'Z' || str[i] >= 'a' && str[i] <= 'z')
            c += str[i];
        else 
            others += str[i];
    }
    
    cout << c << endl;
    cout << num << endl;
    cout << others;
    
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发