山讯网

读入五个字符串,按由小到大的顺序输出(本题要求编写程序读入5个字符串按由小到大的顺序输出)

admin 来源:未知
导读您好,现在渔夫来为大家解答以上的问题。读入五个字符串,按由小到大的顺序输出,本题要求编写程序读入5个字符串按由小到大的顺序输出相信很...

您好,现在渔夫来为大家解答以上的问题。读入五个字符串,按由小到大的顺序输出,本题要求编写程序读入5个字符串按由小到大的顺序输出相信很多小伙伴还不知道,现在让我们一起来看看吧!

1、#include#include#define M 5#define N 20void main(){ char str[M][N],temp[N]; int i,j; for(i=0;i<><><><=m-j-1;i++)   if(strcmp(str[i],str[i+1])>0)   {    strcpy(temp,str[i]);    strcpy(str[i],str[i+1]);    strcpy(str[i+1],temp);   } } printf("排序后:"); for(i=0;i<>

2、供你参考。

本文就为大家分享到这里,希望小伙伴们会喜欢。

标签: