#include <stdbool.h> #include <stdio.h> #include <string.h> bool isword(char c) { if((c>='a'&&c<='z' )||(c>='A'&&c<='Z')) { return true; } else { return false; } } void swap(char* str , int i, int j) { char temp; temp = str[i]; str[i] = str[j]; str[j] = temp; } bool alignandcomparetodecrease(char a, char b) { char tempa = a>'Z'? a-32:a; char tempb = b>'Z'? b-32:b; if(tempa<tempb) { return true; } else { return false; } } void sort(char* str, int length) { for(int i = 0;i<length;i++) { for(int j = length-1;j>i;j--) { if(alignandcomparetodecrease(str[j], str[j-1])) { swap(str, j, j-1); } } } } int main() { char str[1000]; scanf("%[^\n]",str); int nonwordindex[1000]; for(int i =0;i<1000;i++) { nonwordindex[i] =1001; } int len = strlen(str); char tempstr[1000]; char res[strlen(str)]; int index = 0; int tempindex = 0; for(int i =0;i<len;i++) { if(!isword(str[i])) { nonwordindex[index++] = i; } else { tempstr[tempindex++] = str[i]; } } sort(tempstr,strlen(tempstr)); index = 0; int strindex = 0; for(int i =0;i<strlen(str);i++) { if(i==nonwordindex[index]) { index++; printf("%c" ,str[i]); } else { printf("%c",tempstr[strindex++]); } } return 0; }