随笔分类 - 算法
常见算法
摘要:#include "stdio.h" #define MAXSIZE 20 typedef int ElemType; typedef struct { ElemType r[MAXSIZE+1]; int length; }SortList; //简单选择排序 void SelectSort(SortList *L) { int i,j;ElemType t; ...
阅读全文
摘要:/************************************************************************* > File Name: only_one.c > Author: > Mail: > Created Time: Thu 01 Nov 2018 09:21:50 AM CST ***************...
阅读全文
摘要:#include "stdio.h" #define MAXSIZE 20 typedef int ElemType; typedef struct { ElemType r[MAXSIZE+1]; int length; }SortList; /* 冒泡排序:BubbleSort */ void BubbleSort(SortList *L) { int i,j;E...
阅读全文
摘要:#include "stdio.h" #define MAXSIZE 20 typedef int ElemType; typedef struct { ElemType r[MAXSIZE+1]; int length; }SortList; void crelist(SortList *L) { int i = 0; ElemType x; printf("...
阅读全文
摘要:(1)插入排序:将无序序列区中的记录向有序序列区中插入,使有序序列长度增加的排序方法。 (2)交换排序:通过比较记录的关键字大小来决定是否交换记录,从而排定记录所在位置的方法。 (3)选择排序:从无序序列区中选出关键字最小(升序排列)或最大(降序排列)的记录,并将它交换到有序序列区中指定位置的方法。
阅读全文
摘要:/************************************************************************* > File Name: StaticSearchTable.c > Author: > Mail: > Created Time: Fri 21 Dec 2018 03:49:17 PM CST ******...
阅读全文
摘要:转自:https://blog.csdn.net/qq_31029351/article/details/53311285
阅读全文
摘要://1.斐波那契数列 int fibo(int n) { if(n==1 || n==2) { return 1; } else { return fibo(n-1) + fibo(n-2); } } //2.阶乘 int fac(int n) { if(n==1 || n==0) { ...
阅读全文
摘要:刚开始学习冒泡排序的时候老师是这样介绍的。 冒泡排序:遍历要排序的元素列,依次比较两个相邻的元素,如果他们顺序错误,则交换。 算法原理(升序排列):比较第一个和第二个元素,如果第一个比第二个大则交换他们。 对每一个元素都做同样的操作,从第一对到最后一对。这样就可以把最大的元素放到了最后。 再重复以上
阅读全文
浙公网安备 33010602011771号