注意全为0的情况
//
// main.cpp
// PATA1038
//
// Created by Phoenix on 2018/2/10.
// Copyright © 2018年 Phoenix. All rights reserved.
//
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
bool cmp(string a, string b) {
return a + b < b + a;
}
int main(int argc, const char * argv[]) {
int n;
scanf("%d", &n);
string s[n];
for(int i = 0; i < n; i++) {
char num[10];
scanf("%s", num);
s[i] = num;
}
sort(s, s + n, cmp);
string str;
for(int i = 0; i < n; i++) {
str += s[i];
}
while(str[0] == '0') {
str.erase(str.begin()+0);
}
if(str.size()){
cout << str << endl;
} else {
printf("0");
}
return 0;
}
335

被折叠的 条评论
为什么被折叠?



