题解string+sort
2025-06-25 19:27:59
发布于:浙江
0阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
string s,lowers,uppers,numbers,others;
cin>>s;
for (char i:s){
if (isupper(i)) uppers+=i;
if (islower(i)) lowers+=i;
if (isdigit(i)) numbers+=i;
if (ispunct(i)) others+=i;
}
sort(lowers.begin(),lowers.end());
sort(uppers.begin(),uppers.end());
sort(numbers.begin(),numbers.end());
sort(others.begin(),others.end());
cout<<lowers<<uppers<<numbers<<others;
return 0;
}
这里空空如也
有帮助,赞一个