自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(8)
  • 收藏
  • 关注

原创 数据结构与算法八——树

树的存储结构树与二叉树的转换树和森林的遍历哈夫曼树code1:凹入表打印#include<stdio.h>#include<stdlib.h>#include<iostream>using namespace std;const int nmax=100;int f[nmax+1];int s[nmax+1][nmax+1];int tot;char a[nmax];int GetDepth(int x){ if(!s[x][0

2021-05-30 10:25:19 427

原创 数据结构与算法七——矩阵压缩

稀疏矩阵行逻辑链接的顺序表稀疏矩阵的链式储存code稀疏矩阵求转置#include<stdio.h>const int Maxn = 5000;int a[Maxn + 1][3], b[Maxn + 1][3];void tri_trans() { b[0][0] = a[0][1]; b[0][1] = a[0][0]; b[0][2] = a[0][2]; int k = 1; for (int i = 1; i <= a[0][1]; .

2021-05-29 16:46:34 169

原创 数据结构六——动规与贪心

动态规划例1:和最大的连续子序列例2:最长递增子序列最优矩阵乘法贪心算法

2021-05-27 10:42:25 133

原创 数据结构五——递归与分治

递归分治例1 归并排序code#include<stdio.h>using namespace std;void Merge(int a[], int s, int m, int e, int temp[]){ int p = 0, p1 = s, p2 = m + 1; while (p1 <= m && p2 <= e) { if (a[p1] > a[p2]) temp[p++] = a[p1++];

2021-05-26 18:34:21 147

原创 数据结构四——KMP匹配算法

KMP串匹配算法Brute ForceKMPFailure FunctionCodeBF#include <stdio.h>int n, m;char a[500000], b[500000];int Index(char*S, char*T, int pos){ int i=pos-1, j=0; while(i<n){ if(S[i]==T[j]){ ++i; ++j; if(j==m) return i-

2021-05-22 10:57:57 154

原创 数据结构三——栈与队列

栈顺序栈//入栈int push(int s[],int x){ if (top==M) { printf("overflow"); return(-1); } s[top++]=x; return top;}//出栈int pop(int s[], int *q)。{ if (top==0) { printf(“underflow"); return(-1); }

2021-05-19 22:03:31 149

原创 数据结构二——线性表

顺序表Status ListInsert_Sq(SqList &L, int i, ElemType e) {// 在顺序表L的第 i 个元素之前插入新的元素e,// i 的合法范围为 1 ≤ i ≤ L.length+1q = &(L.elem[i-1]); // q 指示插入位置for (p = &(L.elem[L.length-1]); p >= q; --p) //p地址 *(p+1) = *p;

2021-05-16 22:16:29 143

原创 数据结构1——一些小题

数据结构1——一些小题Fibonacci数列的递推公式为:F_n=F_(n-1)+F_(n-2), 其中F_1=F_2=1。求F除以10007的余数是多少。输入格式:输入包含一个正整数n。输出格式:输出一行,包含一个整数,表示F_n除以10007的余数。样例输入:22样例输出:7704#include<iostream>using namespace std;int fibo(int n )//迭代法求斐波那契数列 { if( n <= 0 ) retur

2021-05-13 19:27:11 100

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除