摘要:
/* 二分查找示例示例 -- 只适合已排序数组 Wirtten by: nick Date: 2012-10-16 12:13*/#include <iostream>#include <iomanip>using namespace std;bool binarySearch(int list[], int end, int target, int& index);int main(){ int a[10] = {0,1,2,3,4,5,6,7,8,9}; //已排序数组 int ans=0; if(binarySearch(a, 9, 6, ans))... 阅读全文
posted @ 2012-10-16 14:55
wouldguan
阅读(353)
评论(0)
推荐(0)
摘要:
/* 顺序查找示例示例 Wirtten by: nick Date: 2012-10-16 12:13*/#include <iostream>#include <iomanip>using namespace std;bool seqSearch(int list[], int last, int target, int& index);int main(){ int a[10] = {3,4,6,3,2,8,4,0,5,7}; int ans=0; if(seqSearch(a, 9, 6, ans)) cout << "Find! i 阅读全文
posted @ 2012-10-16 14:40
wouldguan
阅读(807)
评论(0)
推荐(0)
摘要:
/* 插入排序示例 Wirtten by: nick Date: 2012-10-16 12:13*/#include <iostream>#include <iomanip>using namespace std;void insertionSort(int list[], int last);void insertOne(int list[], int current, int last);int main(){ int a[10] = {3,4,6,3,2,8,4,0,5,7}; insertionSort(a, 9); for(int i=0; i<... 阅读全文
posted @ 2012-10-16 14:25
wouldguan
阅读(339)
评论(0)
推荐(0)
摘要:
/* 冒泡排序示例 Wirtten by: nick Date: 2012-10-16 12:13*/#include <iostream>#include <iomanip>using namespace std;void bubbleSort(int list[], int last);void bubbleUp(int list[], int current, int last);int main(){ int a[10] = {3,4,6,3,2,8,4,0,5,7}; bubbleSort(a, 9); for(int i=0; i<10; i++... 阅读全文
posted @ 2012-10-16 12:27
wouldguan
阅读(373)
评论(0)
推荐(0)
摘要:
/* 选择排序实例 Wirtten by: nick Date: 2012-10-16 12:13*/#include <iostream>#include <iomanip>using namespace std;void selectionSort(int list[], int last);void exchangeSmallest(int list[], int current, int last);int main(){ int a[10] = {3,4,6,3,2,8,4,0,5,7}; selectionSort(a, 9); for(int ... 阅读全文
posted @ 2012-10-16 12:15
wouldguan
阅读(254)
评论(0)
推荐(0)
浙公网安备 33010602011771号