69,371
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <string.h>
void main()
{
char (*name)[20] = {"peal","apple","strwaberll","cdfk","ndklfj"};
int i,j,k;
char *temp;
for ( i=1; i<5; i++ )
{
temp = name[i];
for ( j=i-1; j>=0; j-- );
{
if ( strcmp( temp ,name[j] ) < 1 )
strcpy( name[j+1],name[j]);
else
break;
}
strcpy( name[j+1],temp);
}
for ( i=0; i<5; i++ )
{
printf("%s\n",name[i]);
}
}
#include <stdio.h>
#include <string.h>
void main()
{
char namep[5][15]={"peal","apple","strwaber","cdfk","ndklfj"};
char (*name)[15]=namep;
int i,j;
char t[20],*temp=t;
for ( i=1; i<5; i++ )
{
temp = name+i;
for ( j=i-1; j>=0; j-- )
{
if ( strcmp( temp ,name+j ) < 0 )
strcpy( name+j+1,name+j);
else
break;
}
strcpy( name+j+1,temp);
}
for ( i=0; i<5; i++ )
{
printf("%s\n",name+i);
}
}