当前位置: 首页 > news >正文

1038. Recover the Smallest Number (30)

1038. Recover the Smallest Number (30)

#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <vector>using namespace std;int cmp(string a, string b)
{string c = a + b;string d = b + a;return c < d;
}int main()
{int n;scanf("%d", &n);int i;char num[10];vector<string> v;for(i = 1; i <= n; i++){scanf("%s", num);v.push_back(num);}sort(v.begin(), v.end(), cmp);int flag = 0, len, j;char ch;for(i = 0; i <= n - 1; i++){len = v[i].length();for(j = 0; j <= len - 1; j++){ch = v[i][j];if(ch == '0'){if(flag == 1){printf("0");}}else{printf("%c", ch);flag = 1;}}}if(flag == 0){printf("0");}printf("\n");system("pause");return 0;
}