#include <iostream>
using namespace std;
int main()
{
char str[20],name[5][20];
int i,j,p;
cout<<"亲输入5个学生的姓名:"<<endl;
for (i=0; i<5; i++)
{
gets(name[i]);
}
cout<<"姓名升序排列如下:"<<endl;
for (i=0; i<5; i++)
{
p=i;
strcpy(str, name[i]);
for (j=i+1; j<5; j++)
{
if (strcmp(name[j], str)<0)
{
p=j;
strcpy(str, name[j]);
}
}
if (p!=i)
{
strcpy(str, name[i]);
strcpy(name[i], name[p]);
strcpy(name[p], str);
}
puts(name[i]);
cout<<endl;
}
system("pause");
return 0;
}