ASCII码排序:http://acm.nyist.net/JudgeOnline/problem.php?pid=4
绝不重新造轮子。
#include<iostream> #include<string> #include<algorithm> using namespace std; int main() { int n = 0; cin >> n; for (int i = 0; i < n; ++i) //多次测试 { string str; cin >> str; sort(str.begin(), str.end()); str.insert(1, " "); //符合输出要求 str.insert(3, " "); cout << str << endl; } }
时间: 2024-09-27 12:29:35