Submission
Status:
[PPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: DIce
Problemset: เรียงสตริง
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-02 10:23:57
#include <bits/stdc++.h>
using namespace std;
int up[35],down[35];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string str;
cin>>str;
int u=0,d=0,q;
q=str.size();
for(int i=0;i<q;i+=1){
if((int)str[i]<=(int)'Z'){
up[u]=(int)str[i];
u+=1;
}else if((int)str[i]>=(int)'a'){
down[d]=(int)str[i];
d+=1;
}
}
int x,y;
for(int i=0;i<u;i+=1){
for(int j=i+1;j<u;j+=1){
if(up[i]>=up[j]){
x=up[i];
up[i]=up[j];
up[j]=x;
}
}
}
for(int i=0;i<d;i+=1){
for(int j=i+1;j<d;j+=1){
if(down[i]>=down[j]){
y=down[i];
down[i]=down[j];
down[j]=y;
}
}
}
for(int i=0;i<u;i+=1){
if(up[i]>0){
if(i==0||up[i]!=up[i-1]){
cout<<(char)up[i]<<" ";
}
}else break;
}
for(int i=0;i<d;i+=1){
if(down[i]>0){
if(i==0||down[i]!=down[i-1]){
cout<<(char)down[i]<<" ";
}
}else break;
}
return 0;
}