2012年9月6日

基数排序

摘要: //基数排序#include<iostream.h>void funCount(int *count,int* a,int length,int num)//对应位上数字的个数{ for (int i=0;i<length;i++) { int x=a[i]; for (int j=2;j<=num;j++) { x=x/10; } x=x%10; count[x]++; }}void funIndex(int* count,int* index)//对应位上数字开始存放... 阅读全文

posted @ 2012-09-06 15:32 为梦飞翔 阅读(308) 评论(0) 推荐(0)

寻找第K小值

摘要: #include<iostream.h>int findValue(int k,int* a,int start,int end){ int low=start; int high=end; int x=a[start]; int flag=0; while (low!=high) { if (flag==0) { for (int j=high;j>=low;j--) { if (a[j]<x) { ... 阅读全文

posted @ 2012-09-06 10:15 为梦飞翔 阅读(212) 评论(0) 推荐(0)

快速排序

摘要: //快速排序算法#include<iostream.h>void sort(int start,int end,int *a){ if (start>=end) return; int low=start; int high=end; int x=a[start]; int flag=0; while (low!=high) { if (flag==0)//左边空,从右向左找比x小的值 { for(int j=high;j>=low;j--) { ... 阅读全文

posted @ 2012-09-06 09:17 为梦飞翔 阅读(204) 评论(0) 推荐(0)

导航