数据结构常用查询算法
来源:互联网 发布:api数据最新 编辑:程序博客网 时间:2024/06/08 08:29
/**交互两个数据*/inline void swap(int *a,int *b) {int temp;temp = *a;*a = *b;*b = temp;}/**冒泡排序*/void bubbleSort(int len,int table[]) { for (int i = 0; i < len - 1; i++) { for (int j = 0; j < len -1- i; j++) { if (table[j] > table[j + 1]) { swap(&table[j],&table[j+1]); } } }}/**选择排序*/void selectSort(int len, int table[]) { for (int i = 0; i < len; i++) { int k = i; for (int j = i + 1; j < len; j++) { if (table[j] < table[k]) { k = j; } } if (k != i) { swap(&table[i], &table[k]); } }}/*插入排序*/void insertSort(int len, int table[]) { for (int i = 1; i < len; i++) { int j = i - 1; int temp = table[i]; while (j >= 0 && table[j] > temp) { table[j + 1] = table[j]; j--; } table[j + 1] = temp; }}/*快速排序*/void quickSort(int left,int right, int table[]) { if (left < right) { int key = table[left]; int l = left, r = right; while (l < r) { while (l<r && table[r]>key) { r--; } swap(&table[l], &table[r]); while (l<r && table[l] < key) { l++; } swap(&table[l], &table[r]);} quickSort(left, l - 1, table); quickSort(l+1, right, table);}
0 0
- 数据结构常用查询算法
- 数据结构常用算法
- 常用数据结构以及算法
- 数据结构常用算法
- 常用算法和数据结构
- 数据结构之常用算法
- 数据结构常用算法
- 数据结构常用算法实现
- 数据结构和常用算法
- 常用的数据结构算法
- 数据结构常用算法
- 数据结构中常用算法
- 数据结构---常用算法
- 常用数据结构及算法
- 常用数据结构与算法
- 【数据结构】数据结构中常用的排序算法
- java常用数据结构排序算法
- 常用的数据结构以及算法
- 比特币今日行情
- 比特币行情走势图
- 比特币今日价格行情
- 比特币价格今日的价格
- 比特币走势
- 数据结构常用查询算法
- 比特币投资风险
- javascript学习笔记
- 比特币挖矿软件
- 比特币价格走势
- 比特币区块查询
- 比特币是否合法
- 挖比特币
- 如何让摄影图片保持清晰 利用智能图层保证图片的清晰