#include<iostream> #include<cstring> using namespace std; bool jude(string s1, string s2) { //判断s1是否比s2大 if (s1.size() < s2.size())return false; if (s1.size() > s2.size())return true; int i = 0; while (s1[i] == s2[i] && i < s1.size())i++; if (i < s2.size() && s1[i] > s2[i])return true; else return false; } int main() { int n; while (cin >> n) { string* s = new string[n]; for (int i = 0; i < n; i++)cin >> s[i]; for (int i = 0; i < n - 1; i++) for (int j = 0; j < n - i - 1; j++) if (jude(s[j], s[j + 1]))swap(s[j], s[j + 1]); for (int i = 0; i < n; i++)cout << s[i] << endl; } return 0; }