c语言试题。。。。。 通过指针计数组队若干字符串按字母顺序(由小到大)输出 :char※nam

c语言试题。。。。。 通过指针计数组队若干字符串按字母顺序(由小到大)输出 :char※name[]={“follow”,“basic”,“great wall”,“fortran”,“computer”} 跪求大神

//刚写的code,测试通过,如果有疑问,欢迎交流
#include<stdio.h>
#include<string.h>
#define N 100
void bubblesort_str(char list[][N],int len) //冒泡排序
{
    int i,j;
char temp[N];
    for(i=0;i<len - 1;i++)
        for(j=0;j<len-i - 1;j++) 
        {
            if(strcmp(list[j+1], list[j]) < 0)
            {
                strcpy(temp,list[j+1]);
                strcpy(list[j+1], list[j]);
                strcpy(list[j] ,temp);
            }
        }
}
int main(){
char name[5][N] = {"follow","basic","great wall", "fortran", "computer"};
bubblesort_str(name, 5);
int i;
for(i = 0; i<5; i++){
puts(name[i]);
}
}

追问

大哥,说句题外话, 71354班的别看,老师说了雷同就零分,自重自重。。

温馨提示:答案为网友推荐,仅供参考
相似回答