c语言实现冒泡排序
2018-01-06 22:28
405 查看
#include <stdio.h> |
#include <string.h> |
char words[10][6]={ "dszcr" , "dwcrg" , "cueuz" , "nufas" , "rgvzu" , "fesiu" , "fwehs" , "dqhzo" , "woajz" , "hgruk" }; |
char * temp[10]; |
void sort(); |
void sortonce( char *strings[], int num) { |
char *temp; |
int top ,seek; |
//对字符串指针进行排序 |
for (top=0; top< num-1;top++ ) |
for (seek = top+1;seek<num;seek++) |
//对字符串进行比较strcmp |
if ( strcmp (strings[top] ,strings[seek] ) > 0) |
//交换排序 |
{ |
temp = strings[top]; |
strings[top] = strings[seek]; |
strings[seek]= temp; |
} |
} |
void sort() { |
int i,j; |
for (i=0;i<=9;i++) temp[i]=words[i]; |
sortonce(temp,10); |
} |
int main() { |
int i; |
sort(); |
for (i=0;i<=9;i++) { |
printf ( "%s," ,temp[i]); |
} |
return 0; |
} |
相关文章推荐
- 用c语言实现冒泡排序,选择排序,快速排序
- C语言实现对数组中的数据进行冒泡排序(从小到大)
- 图解排序算法及C语言实现之 ------ 冒泡排序:Bubble Sort
- C语言实现基本排序算法----排序(直接插入排序,SHELL排序,冒泡排序,快速排序,简单选择排序,堆排序)
- 用c语言指针实现给整形数组冒泡排序
- C语言实现直接插入排序,冒泡排序以及二分查找(巩固理解记忆)
- 实现冒泡排序(c语言)
- C语言指针实现冒泡排序
- C语言实现冒泡排序
- C语言实现选择排序、直接插入排序、冒泡排序的示例
- C语言实现冒泡排序
- C语言实现冒泡排序-整数排序
- [算法练习]冒泡排序的C语言实现
- c语言实现冒泡排序、希尔排序等多种算法示例
- C语言实现冒泡排序
- 数据结构之---C语言实现冒泡排序
- 排序算法的C语言实现-冒泡排序
- c语言实现冒泡排序
- 排序(3)---------冒泡排序(C语言实现)
- C语言-用指针实现冒泡排序