當前位置:成語大全網 - 書法字典 - c語言輸入五個字母,然後按字典順序輸出。怎麽了?

c語言輸入五個字母,然後按字典順序輸出。怎麽了?

您輸入的是五個字符串排序的代碼,而不是五個字符排序的代碼。

保持

strcpy(word[i],temp);

strcpy(word[j],word[I]);

strcpy(temp,word[j]);

換成

strcpy(temp,word[I]);

strcpy(word[i],word[j]);

strcpy(word[j],temp);

put for(I = 1;我& lt5;I++)更改為for(I = 0;我& lt5;i++).

Printf("%s ",word[I][20]);改為printf("%s ",word[I]);。