算法
宇宙蛋
数学爱好者 研究领域为ml+rs 偶尔捣鼓下代码
展开
-
快速排序
#include #include #include using namespace std; /* * 交换两个数 */ void exchange(unsigned int *p,unsigned int *q) { unsigned int temp; temp=*p; *p=*q; *q=temp; } /* * 快速排序 * */ unsigned i原创 2014-10-15 17:02:59 · 711 阅读 · 0 评论 -
二分查找 递归与非递归 编程之美写法
#include using namespace std; /** 二分查找 * * key 待查找元素 * begin 数组起始位置 * end 数组结束位置 * 返回值为待查找的元素在数组位置 若找不到 则返回-1 * */ int BinarySearch(int array[], int begin, int end,int key) { while(原创 2014-10-15 16:58:50 · 797 阅读 · 0 评论