//排序函数
void sortOfStrings(char *p[],int count)
{
char *temp= NULL;
for (int i = 0 ; i < count- 1; i++) {
for (int j = 0 ; j < count - 1 - i; j++) {
if (strcmp(*( p+j), *(p+j +1)) > 0) {
temp = *(p+j);
*( p+j)= *(p+j +1);
*(p+j +1)=temp;
}
}
}
}
//输出函数
void outOfStrings(char *p[],int count)
{
for (int i = 0 ; i < count; i ++) {
printf("%s ",*(p+i));
}
}
int main(int argc, const char * argv[])
{
char *str[5]= {"sun","zhang","tang","wang","he"};
sortOfStrings(str , 5);
printf("排序后为:");
outOfStrings(str, 5);
return 0;
<h3>}</h3>
最后
以上就是火星上冰棍最近收集整理的关于在主函数中输入5个的字符串。用另一个函数对它们排序,然后主函数输出5个已经排好的字符串 的全部内容,更多相关在主函数中输入5个的字符串。用另一个函数对它们排序,然后主函数输出5个已经排好的字符串内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复