- 博客(10)
- 资源 (1)
- 收藏
- 关注
原创 桶排序
#include #include #include #define BASE 10 using namespace std; //桶中元素链表 typedef struct entry { int element; struct entry *next; }ENTRY; //维护每个桶中元素数目,并且指向第一个元素 typedef struct buc { int size; ENT
2015-11-28 16:18:00 233
原创 基数排序
#include #include #include #define BASE 10 using namespace std; void base_sort(int arr[], int n, int num_length) { int i = 1; int flag = 1; while (i <= num_length) { int length = 1; int A = s
2015-11-19 22:28:10 239
原创 堆排序
示意图如下: 代码如下: #include #include using namespace std; void keep_heap(int arr[], int i,int heap_size) { int Left = i * 2; int Right = 2 * i +1 ; int
2015-11-18 22:38:30 291
原创 杭电acm--2187
汶川地震救灾物资 现在假设下拨了一定数量的救灾经费要去市场采购大米(散装)。如果市场有m种大米,各种大米的单价和重量已知,请问,为了满足更多灾民的需求,最多能采购多少重量的大米呢? Input 输入数据首先包含一个正整数C,表示有C组测试用例,每组测试用例的第一行是两个整数n和m(0 Output 对于每组测试数据,请输出能够购买大米的最多重量(你可以假设经费买不光所有的大
2015-11-13 16:41:02 748
原创 杭电acm--2111
话说上回讲到海东集团面临内外交困,公司的元老也只剩下XHD夫妇二人了。显然,作为多年拼搏的商人,XHD不会坐以待毙的。 一天,当他正在苦思冥想解困良策的时候,突然想到了自己的传家宝,那是公司成立的时候,父亲作为贺礼送来的一个锦囊,徐父当时交代,不到万不得已的时候,不要打开它。“现在不正是最需要的时候吗?”,一边想,XHD一边找到了这个精心保管的锦囊,打开一看,里面只有一句话“杭城北麓千人洞有
2015-11-13 15:51:27 406
原创 归并排序
示意图如下: 代码如下: #include using namespace std; void merge(int A[], int B[], int arr[], int lengthA, int lengthB) { int i = 0, j = 0,count=0; while (count<lengthA+lengthB) { if (A[i]
2015-11-10 22:15:55 264
原创 希尔排序
代码如下: #include using namespace std; void shell_sort(int arr[], int n) { int flag,i,j,length = n; while (length > 1) { length = length / 2; do{ flag = 0; for (i = 0; i < n - length;
2015-11-10 21:26:27 224
原创 选择排序
代码如下: #include using namespace std; void select_sort(int *arr, int n) { int i, j; int max; for (i = 0; i < n - 1; i++) { max = i; for (j = max + 1; j < n; j++) { if (arr[max] > arr[
2015-11-08 20:43:53 259
原创 快速排序
示意图如下: 下标0暂存i,不参与排序 代码如下: #include //#include using namespace std; int partition(int arr[], int begin_index, int end_index) { int key = arr[end_index]; int i = begin_index-1; for
2015-11-01 16:35:12 286
原创 计数排序
示意图如下: 代码如下: #include //#include using namespace std; void counting_sort(int arr1[], int arr2[], int temp_arr[], const int arr_num, const int bigest_num) { for (int i = 0; i <= bige
2015-11-01 14:15:51 231
通讯簿管理系统
2015-09-20
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人