C++语言版本的: #include "iostream" #include "string" #include "algorithm" using namespace std; bool cmp(string &a, string &b) { return a<b; } int main(void) { int n,i; string *str; cout<<"请输入字符串的个数:"; cin>>n; str = new string[n]; for(i = 0; i < n; i++) cin>>str[i]; sort(str, str+n, cmp); cout << "排序后的结果为:" <<endl; for(i = 0; i < n; i++) cout<<str[i]<< endl; system("pause"); return 0; } 运行结果如下图: