#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main ( )
{
int i;
int j;
char *temp=0;
char a[5][200];
printf ("请输入6个字符串\n");
for (i=0; i<6;i++)
{
printf ("请输入第%d个字符串",i+1);
gets(a[i]);
}
for (i=0;i<5;i++)
{
for(j=0;j<5-i;j++)
{
if (strcmp(a[i],a[i+1])>0)
{
strcpy(temp,a[i]);
strcpy(a[i],a[i+1]);
strcpy(a[i+1],temp);
}
}
}
for (i=0;i<6;i++)
{
printf("第%d个字符串:%s\n",i+1,a[i]);
}
return 0;
}
|
|