dame
2023-12-27 19:47:11
发布于:广东
16阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
void arrange(){
string s;
cin >> s;
char c1[100000], c2[100000], c3[100000], c4[100000];
int n1 = 0, n2 = 0, n3 = 0, n4 = 0;
int len = s.length();
for(int i = 0; i < len; i++){
if(s[i] >= '0' && s[i] <= '9'){
c1[n1++] = s[i];
}else if(s[i] >= 'a' && s[i] <= 'z'){
c2[n2++] = s[i];
}else if(s[i] >= 'A' && s[i] <= 'Z'){
c3[n3++] = s[i];
}else{
c4[n4++] = s[i];
}
}
sort(c1, c1 + n1);
sort(c2, c2 + n2);
sort(c3, c3 + n3);
sort(c4, c4 + n4);
for(int i = 0; i < n2; i++){
cout << c2[i];
}
for(int i = 0; i < n3; i++){
cout << c3[i];
}
for(int i = 0; i < n1; i++){
cout << c1[i];
}
for(int i = 0; i < n4; i++){
cout <<c4[i];
}
return ;
}
int main(){
arrange();
return 0;
}
这里空空如也
有帮助,赞一个