冒泡法排序及排序结果校验
2013-07-08 16:23
169 查看
#include <iostream> bool CheckSort(int * pSource, int N); bool Sort(int * pSource, int N); int main() { using std::cout; using std::endl; const int SIZE =10; int a[10] ={-65,10,33,-2,81,-89,0,14,142,3}; bool isSort = false,isSortStatus; isSortStatus =CheckSort(a,SIZE); if (isSortStatus) cout <<"Sorted...\n"; else cout <<"Unsorted..\n"; ///////////////////////////////////////////// cout<<">>>Sorting...\n"; isSort =Sort(a,SIZE); if (isSort) for (int i = 0; i cout<< i+1<< "--->"<< a[i]<< endl; else cout << "Sortfail.\n"; //////////////////////////////////////////// isSortStatus =CheckSort(a,SIZE); if (isSortStatus) cout <<"Sorted...\n"; else cout <<"Unsorted..\n"; return 0; } bool CheckSort(int * pSource, int N) { bool Check =false; for (int i=0; i { if ( *(pSource+i) <=*(pSource+i+1) ) Check =true; else Check =false; if (!Check) break; } return Check; } bool Sort(int * pSource, int N) { int tmp; for (int i=0; i { for (int j=0; j { if (*(pSource+j) > *(pSource+j+1) ) { tmp = *(pSource+j); *(pSource+j) =*(pSource+j+1); *(pSource+j+1) = tmp; } } } return true; }
相关文章推荐
- 快排第n趟排序结果校验
- 网站搜索设计之——————关于搜索结果排序的设计
- 三个数排序。要求输入三个整数,按逗号隔开,把它们从小到大排列,输出结果用空格隔开。
- MySQL中对查询结果排序和限定结果的返回数量的用法教程
- 搜索结果按匹配字段进行排序
- alpha发布排序结果
- preg_match_all 结果排序之PREG_SET_ORDER参数
- 浅析SQL查询语句未显式指定排序方式,无法保证同样的查询每次排序结果都一致的原因
- oracle 给查询结果排序
- jQuery实现拖动排序并将排序结果保…
- jQuery插件Validate实现自定义校验结果样式
- mysql在查询结果中增加排序字段
- wm_concat,对结果进行排序
- DEDE5.6织梦5.7搜索结果按点击排序-最新原创可用代码
- SQLServer排序时与读取的记录会影响到结果?
- SQL SERVER中对查询结果随机排序
- elasticsearch5.2搜索结果排序
- jQuery拖动布局实现排序结果同步数据库
- 昌泡排序的结果从小到大
- 接口测试之结果校验