typedef struct { int i; char c; } e; const int N = 1000; char s[N]; e a[N]; int cmp(const void* a, const void* b) { e x = *(e*)a, y = *(e*)b; if (x.c > 'Z') x.c -= 32; if (y.c > 'Z') y.c -= 32; return x.c != y.c ? x.c - y.c : x.i - y.i; } int main() { while (gets(s)) { int n = strlen(s), m = 0; for (int i = 0; i < n; i++) if (isalpha(s[i])) { a[m].i = i; a[m].c = s[i]; m++; } qsort(a, m, sizeof(e), cmp); for (int i = 0, j = 0; i < n; i++) if (isalpha(s[i])) s[i] = a[j++].c; puts(s); } return 0; }