导读 大家好,小康来为大家解答以上问题。www,sao24 com很多人还不知道,现在让我们一起来看看吧!
include stdio h
include str
大家好,小康来为大家解答以上问题。www,sao24 com很多人还不知道,现在让我们一起来看看吧!
#include 'stdio.h '
#include 'string.h '
int main()
{
char str[10][30]={ 0 };
int i,j;
char tmp[30]={ 0 };
printf('请输入10个国家的名字(英文): \ n’);
for(I=0;i10我)
gets(str[I]);
//排序:
for(I=0;i9;我)
for(j=I ^ 1;j10j)
if(strcmp(str[i],str[j])0)
{
memset(tmp,0,30);
strncpy(tmp,str[i],strlen(str[I]));
memset(str[i],0,30);
strncpy(str[i],str[j],strlen(str[j]));
memset(str[j],0,30);
strncpy(str[j],tmp,strlen(tmp));
}
//输出
printf('从小到大输出: \ n’);
for(I=0;i10我)
puts(str[I]);
}
本文到此结束,希望对大家有所帮助。