文章
7
粉丝
0
获赞
14
访问
235
#include <bits/stdc++.h>
using namespace std;
bool compare(char c, char b) {
return tolower(c) < tolower(b); // 忽略大小写排序
}
int main() {
string s;
while (getline(cin, s)) {
string c;
for (char x : s) {
if (isalpha(x)) c += x;
}
stable_sort(c.begin(), c.end(), compare);
int j = 0;
for (char x : s) {
if (isalpha(x)) cout << c[j++]; // 替换字母
else cout << x; // 非字母直接输出
}
cout << endl;
}
}
登录后发布评论
暂无评论,来抢沙发