#include<iostream>
#include<string>//字符串类头文件
using namespace std;
int main()
{
string str[25], t;
int n;
cout << "请输入字符串长度:" << endl;
cin >> n;
cout << "请输入需要排序的字符串:" << endl;
int sum = 0;
for (int i = 0;i < n;i++)
cin >> str[i];
for (int i = 0;i < n-1;i++)//比较趟数
{
for (int j=0;j<n-i-1;j++)//每趟比较次数
{
if (str[j] > str[j + 1])
{
t = str[j];
str[j] = str[j + 1];
str[j + 1] = t;
}
}
}
cout << "按字母从小到大的排序为:" << endl;
for (int j = 0;j < n;j++)
cout << str[j] << " ";
return 0;
}