
世界经典算法问题交流探讨
文章平均质量分 67
lionkid
这个作者很懒,什么都没留下…
展开
-
二分法~~
二分法~~很出名阿~这个~以下内容为程序代码:int binarysearch(int p[],int n, int value, /* 查找值 */ int *m) /* 返回的是第一个大于等于查找值的元素 * 位置和小于查找值的元素个数 */ { int op=0; int i=0; /* 头指针前面的元素小于查找值原创 2005-08-27 23:30:00 · 792 阅读 · 0 评论 -
递归-回溯法求解8皇后问题
以下内容为程序代码:/* 本程序使用递归-回溯法求解8皇后问题。Visual C++ 6.0 调试通过。 */ #include #include #include #define QUEENS 8 int iCount = 0; int Site[QUEENS]; void Output(void); void Queen(int n); int IsValid(int n); /*---原创 2005-08-27 23:36:00 · 1758 阅读 · 1 评论 -
基数排序算法
以下内容为程序代码:int quicksort(int p[],int n); extern int insertsort(int p[], int n); static int partition(int p[],int n,int *m); static int quick_sort(int p[],int n); /* * 快速排序算法在 1962 年由 C. Hoare 发明。 * 不稳定原创 2005-08-27 23:34:00 · 3402 阅读 · 0 评论 -
两路归并排序算法
以下内容为程序代码:#include int mergesort(int p[], int n); extern int insertsort(int p[], int n); extern int stablesort(int p[], int n); static int merge_sort(int p[], int swap[], int n, int count); static in原创 2005-08-27 23:33:00 · 1667 阅读 · 0 评论 -
就地归并排序算法的未做优化实现
以下内容为程序代码:int imergesort(int p[], int n); extern int insertsort(int p[], int n); extern int appendsort(int p[], int m, int n); extern int binarysearch(int p[],int n, int v, int *m); static int exchang原创 2005-08-27 23:32:00 · 1231 阅读 · 0 评论 -
堆排序
以下内容为程序代码:int heapsort(int p[],int n); /* * 堆排序算法在 1964 年由 J. Williams 发明。* 不稳定,不需要辅助空间。*/static int insertheap(int p[],int i,int n);int heapsort(int p[],int n){int op=0;int i,temp;/* 从叶子节点建立对应的上级根节点来原创 2005-08-27 23:32:00 · 1893 阅读 · 0 评论 -
几种简单排序
以下内容为程序代码:int selectsort(int p[], int n); int insertsort(int p[],int n); int appendsort(int p[], int m, int n); int bubblesort(int p[],int n); int combsort(int p[], int n); int bubblesort(int p[], int原创 2005-08-27 23:31:00 · 696 阅读 · 0 评论 -
Shell 排序算法(递减增量排序算法)
/* * Shell 排序算法在 1959 年由 D. Shell 发明。 * 也称为递减增量排序算法,各种实现在如何进行递减上有所不同。 * 不稳定,不需要辅助空间。 */ /* * Gonnet 算法,发表于 1991 年。 */ int shellsortGo(int p[],int n) { int op=0; int h,i,j,temp; for(h=n; h>1;原创 2005-08-27 23:28:00 · 1464 阅读 · 0 评论 -
前几天在网上看到有人提到这样一个问题:
前几天在网上看到有人提到这样一个问题: 打印类似下面的: 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 程序: 以下内容为程序代码:#include main() { int i,j,n,k,k1,k2,p; while (1) { printf("Please input a nu原创 2005-08-27 23:27:00 · 772 阅读 · 0 评论 -
8皇后问题改进~
以下内容为程序代码:/* * 8皇后问题: *在第一个的基础上,我对那个java实现稍做修改,添加 *一个计时器计时,时间好象缩短到原来的十分之一,不过不 *能实现n皇后功能,不过我觉得原来那样太慢,20个皇后也要 *跑半天,没多大意义,所以也就无所谓了。 * *不足之处还请多多指教,谢谢!!! * * */ public class Queen8 { int size=8;原创 2005-08-27 23:26:00 · 925 阅读 · 0 评论 -
八皇后问题
八皇后问题: 代码:以下内容为程序代码:〖问题描述〗 在一个8×8的棋盘里放置8个皇后,要求每个皇后两两之间不相"冲"(在每一横列竖列斜列只有一个皇后)。 〖问题分析〗(聿怀中学 吕思博) 这道题可以用递归循环来做,分别一一测试每一种摆法,直到得出正确的答案。主要解决以下几个问题: 1、冲突。包括行、列、两条对角线: (1)列:规定每一列放一个皇后,不会造成列上的冲突; (2)行:当第I行被某个皇原创 2005-08-27 23:00:00 · 1660 阅读 · 0 评论 -
AVL 树数据结构
以下内容为程序代码:/* avl.h */ /* * 高度平衡二*树的一种重要方案。 * 在 1962 年由 G. Adelson-Velsky 和 E. Landis 发明。 */ typedef int typekey; typedef struct avlnode { /* 高度平衡树节点 */ typekey k; /* 键 */ char *v; /* 值 */原创 2005-08-27 23:35:00 · 1175 阅读 · 1 评论 -
双向搜索算法
typedef struct _POINT{ int nx; int ny;}POINT; typedef struct _WORLDUNIT{ BYTE nColorIndex;//颜色索引 boolean bClear; // boolean bFind; //是否已经查找过了… POINT Father;原创 2005-08-27 23:51:00 · 1485 阅读 · 1 评论