1038 贪心
来源:互联网 发布:云服务器支持java 编辑:程序博客网 时间:2024/06/05 16:35
get到一个新的技能;
s.erase(s.begin())可以把0(这里是begin)去掉
#include <string>#include <iostream>#include <algorithm>using namespace std;bool cmp0(string a, string b) { return a + b < b + a;}string str[10010];int main() { int n; scanf("%d", &n); for(int i = 0; i < n; i++) cin >> str[i]; sort(str, str + n, cmp0); string s; for(int i = 0; i < n; i++) s += str[i]; while(s.length() != 0 && s[0] == '0') s.erase(s.begin()); if(s.length() == 0) cout << 0; else cout << s; return 0;}