rewrw
2015-12-13 10:16
323 查看
#include <stdio.h> #define SIZE 8 void bubble_sort( int a[], int n); void bubble_sort( int a[], int n) { int i, j, temp; for (j = 0; j < n - 1; j++) for (i = 0; i < n - 1 - j; i++) { if (a[i] > a[i + 1]) { temp = a[i]; a[i] = a[i + 1]; a[i + 1] = temp; } } } int main() { int number[SIZE] = {95, 45, 15, 78, 84, 51, 24, 12}; int i; bubble_sort(number, SIZE); for (i = 0; i < SIZE; i++) { printf ( "%d" , number[i]); } printf ( "\n" ); } |
相关文章推荐
- Add Two Numbers
- c语言学习笔记之文件包含
- Flex tree项目行上加toolTip提示(两种实现方式)
- multiset
- c语言学习笔记之条件编译
- 【bzoj1023】[SHOI2008]cactus仙人掌图
- python基础教程共60课-第35课continue
- zhphpframework(二十六) php+mysql 分页类
- 三个数混合运算和三层架构
- java 调试技巧
- android 常见的解决(mdpi、hdpi 、xhdpi、xxhdpi )屏幕调整
- [TroubleShooting]'trn\bak' is incorrectly formed. SQL Server cannot process this media family.
- 杭电ACM2576
- C#学习笔记——连接sqlserver数据库
- c语言学习笔记之宏定义
- 空类大小 http://blog.csdn.net/ianchoi/article/details/6335908
- Qt中文乱码问题
- 为什么 Linux Mint 比 Ubuntu好?
- HDU 5596 GTW likes gt 优先队列 BestCoder#66
- zhphp framework(二十五) mongodb 类