算法与数据结构
用类C语言实现
越太
这个作者很懒,什么都没留下…
展开
-
纯C语言--希尔排序
#include<stdio.h>#define N 11 //定义表长为11void ShellInsert(int L[N],int dk){ int j; for(int i=dk;i<N;i++) { if(L[i]<L[i-dk]) { int x=L[i]; for(j=i-dk;j>=0&&(x<L[j]);j-=dk) L[j+dk]=L[j]; L[j+dk]=x; }//if }//原创 2020-06-12 20:56:41 · 277 阅读 · 0 评论 -
纯C语言程序设计---冒泡法排序
#include<stdio.h>#define N 5void Bubble(int a[N]){ int t; for(int i=0;i<N-1;i++) { for(int j=0;j<N-i-1;j++) { if(a[j]>a[j+1]) { t=a[j]; a[j]=a[j+1]; a[j+1]=t; } } }}main(){ int a[N]; printf("输入%d个数\n",原创 2020-06-12 20:54:48 · 1086 阅读 · 0 评论 -
纯C语言--快速排序法
#include<stdio.h>#define N 7 //定义序列长度为7int Partition(int *r,int low,int high) //对子表r进行排序,返回枢轴位置{ int pivotkey; pivotkey=r[low]; //保存关键字 while(low<high) { while(low<high&&r[high]>=pivotkey) high--; r[low]=r[high];原创 2020-06-12 20:49:33 · 186 阅读 · 0 评论 -
C语言程序设计--算法与数据结构之 堆排序
此代码可以运行,下附有运行区//算法8.9 堆排序#include<stdio.h>#include<stdlib.h>#define MAXSIZE 20 //顺序表的最大长度typedef struct{ int key; char *otherinfo;}ElemType;//顺序表的存储结构 typedef struct{ ElemType *r; .原创 2020-05-14 18:41:52 · 581 阅读 · 0 评论 -
C语言程序设计--算法与数据结构之 建立初堆(大根堆)
此代码可以正常运行,下附有运行区//算法8.8 建初堆#include<stdio.h>#include<stdlib.h>#define MAXSIZE 20 //顺序表的最大长度typedef struct{ int key; char *otherinfo;}ElemType;//顺序表的存储结构 typedef struct{ ElemType *r; .原创 2020-05-14 18:34:45 · 1507 阅读 · 1 评论 -
C语言程序设计--算法与数据结构 之 筛选法调整堆
此代码可以正常运行,下附有运行区//算法8.7 筛选法调整堆#include<stdio.h>#include<stdlib.h>#define MAXSIZE 20 //顺序表的最大长度typedef struct{ int key; char *otherinfo;}ElemType;//顺序表的存储结构 typedef struct{ ElemType *r; .原创 2020-05-14 17:33:39 · 1526 阅读 · 0 评论 -
C语言程序设计--算法与数据结构之相邻两个有序子序列的归并
此代码可以正常运行,下附有运行区//算法8.10 相邻两个有序子序列的归并#include <stdio.h>#include<stdlib.h>#define MAXSIZE 20 //顺序表的最大长度typedef struct{ int key; char *otherinfo;}RedType; void Create_Sq(RedType *R){ int i,n; prin.原创 2020-05-14 16:21:52 · 1334 阅读 · 0 评论 -
C语言程序设计--算法与数据结构之 简单选择排序
此代码可以正常运行,下附有运行区//算法8.6 简单选择排序#include <stdio.h>#include<stdlib.h>#define MAXSIZE 20 //顺序表的最大长度typedef struct{ int key; char *otherinfo;}ElemType;//顺序表的存储结构 typedef struct{ ElemType *r;.原创 2020-05-14 15:15:55 · 393 阅读 · 0 评论 -
C语言程序设计--算法与数据结构之 快速排序
此代码可以正常运行,下附有运行区//算法8.5 快速排序#include <stdio.h>#include<stdlib.h>#define MAXSIZE 20 //顺序表的最大长度typedef struct{ int key; char *otherinfo;}ElemType;//顺序表的存储结构 typedef struct{ ElemType *r; .原创 2020-05-14 15:03:34 · 288 阅读 · 0 评论 -
C语言程序设计--算法与数据结构之 希尔排序
此代码可以正常运行,下附有运行区//算法8.3 希尔排序#include <stdio.h>#include<stdlib.h>#define MAXSIZE 20 //顺序表的最大长度typedef struct{ int key; //关键项 char *otherinfo; //其他项}ElemType;//顺序表的存储结构 .原创 2020-05-14 14:23:20 · 410 阅读 · 0 评论 -
C语言程序设计--算法与数据结构---冒泡排序
此代码可以正常运行//算法8.4 冒泡排序#include <iostream>using namespace std;#define MAXSIZE 20 //顺序表的最大长度typedef struct{ int key; char *otherinfo;}ElemType;//顺序表的存储结构 typedef struct{ ElemType *r; .原创 2020-05-12 22:14:07 · 300 阅读 · 0 评论 -
C语言实现--算法与数据结构---折半插入排序
此代码可以正常运行//算法8.2 折半插入排序#include <stdio.h>#include<stdlib.h>#define MAXSIZE 20 //顺序表的最大长度typedef struct{ int key; char *otherinfo; //其他数据项}ElemType;//顺序表的存储结构 typedef struct{ ElemType *.原创 2020-05-11 23:38:07 · 603 阅读 · 0 评论 -
C语言实现--算法与数据结构---直接插入排序
此代码可以正常运行//算法8.1 直接插入排序#include <stdio.h>#include<stdlib.h>#define MAXSIZE 20 //顺序表的最大长度typedef struct{ int key; //关键字 char *otherinfo; //其他数据项}ElemType;//顺序表的存储结构 typedef struct{ .原创 2020-05-11 19:27:43 · 459 阅读 · 0 评论