#include <stdio.h>
#include <string.h>
//使用选择排序
void swiftStr(int *a[], int len){
for (int i = 0; i < len-1; i ++) {
for (int j = 0; j < len - i -1; j ++) {
if (strcmp(a[j], a[j+1])) {
char *temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
}
int main(int argc, const char * argv[])
{
//定义字符串数组
int *a[5]={"abc","efg","KKK","Pew","lala"};
swiftStr(a, 5);
for (int i = 0; i < 5; i ++) {
printf("%st", a[i]);
}
printf("n");
return 0;
}
最后
以上就是霸气煎蛋最近收集整理的关于C经典 使用选择排序排列字符串数组的全部内容,更多相关C经典内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复