當前位置:成語大全網 - 書法字典 - c字典屬性排序

c字典屬性排序

# include & ltstdio.h & gt

# include & ltstring.h & gt

void main()

{

void sort(char * s【】,int n);

static char * name【5】= {“basic“、“fortran“、“cobol“、“pascal“、“c“};

int I;

sort(name,5);

Printf(“新排序字符串:\ n“);

for(I = 0;我& lt5;i++)

puts(name【I】);

}

void排序(char *s【】,int n ){

char * t;

int i,j,k;

for(I = 0;我& ltn-1;i++){

k = I;

for(j = I+1;j & ltn;j++)

if(strcmp(s【k】,s【j】)& gt;0)k = j;

如果(k!=i)

t = s【I】,s【I】= s【k】,s【k】= t;

}

}