注意:最小数为0时,要输出“0”
AC代码
#include#include #include #include using namespace std;bool cmp(const string& a,const string& b){ string reta,retb; reta = a + b; retb = b + a; if(reta < retb) return true; else return false;}int main(){ int n; vector v; scanf("%d",&n); for(int i = 0;i < n;i++){ string tmp; cin >> tmp; v.push_back(tmp); } sort(v.begin(),v.end(),cmp); bool first(true); for(int i = 0;i < v.size();i++){ for(int j = 0;j < v[i].size();j++){ if(first && v[i][j] != '0' || !first){ printf("%c",v[i][j]); first = false; } } } if(first) printf("0\n"); return 0;}