题目:有n个数字(n <= 50),输出由这n个数字组成的最大字符串。
解法:排序即可,坑点在于不能直接利用字符串之间的比较,例如90和9,如果采用字符串比较的话答案是909,而事实是990,所以在比较两个字符串时采用判断a + b 和 b + a的值。
代码:
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
const int maxn = 50 + 10;
string s[maxn];
int