C 语言实例 – 字符串排序 2021年12月7日 20:52:442021年12月7日C语言教程评论1,862 雨后池塘,个人日记空间!点击进入» C 语言实例 - 字符串排序 按字典顺序排序。 实例 #include<stdio.h> #include <string.h> int main() { int i, j; char str[10][50], temp[50]; printf("输入10个单词:\n"); for(i=0; i<10; ++i) { scanf("%s[^\n]",str[i]); } for(i=0; i<9; ++i) { for(j=i+1; j<10 ; ++j) { if(strcmp(str[i], str[j])>0) { strcpy(temp, str[i]); strcpy(str[i], str[j]); strcpy(str[j], temp); } } } printf("\n排序后: \n"); for(i=0; i<10; ++i) { puts(str[i]); } return 0; } 输出结果为: 输入10个单词: C C++ Java PHP Python Perl Ruby R JavaScript PHP 排序后: C C++ Java JavaScript PHP PHP Perl Python R Ruby 历年同日文章 12 月7 2020Windows必装软件IDM(优秀下载工具)v6.38.14 完美**版 点赞 登录收藏 https://www.gongshiku.com/html/202112/c-yuyanshili-zifuchuanpaixu.html 复制链接 复制链接 运营不易, 感谢支持! 我的微信 微信号已复制 我的微信公众号 我的微信公众号扫一扫 我的公众号 公众号已复制