自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 排序:基本排序算法合集

#include<iostream>using namespace std;/*直接插入排序*/void DirectInsert(int r[],int n){ for (int i = 2; i <= n; i++) { r[0] = r[i]; int j = i - 1; while (r[0] < r[j]) { r[j + 1] = r[j]; j--; } r[j+1] = r[0]; }}/*希尔排序*/voi.

2021-12-22 10:23:26 182 1

原创 二叉树:中序线索二叉树

#include<iostream>using namespace std;typedef struct BiNode{ int data; BiNode* lchild, * rchild; int ltag, rtag;};//中序线索链表的建立void InThread(BiNode* p){ static BiNode* pre = NULL; if (p == NULL) return; InThread(p->lchild); //左子树线.

2021-11-29 14:58:45 344

转载 二叉树:创建与遍历(递归/非递归)

#include<iostream>#include<queue>#include<stack>#include < iomanip >using namespace std;typedef struct tree { char value;//结点值 tree* lchild;//左子树指针 tree* rchild;//右子树指针};void creat_tree(tree*& T)//创建二叉树{ char ch; .

2021-11-20 20:53:31 154

原创 非递归:Ackerman函数

#include<iostream>using namespace std;/*问题描述akm(m,n)=1.当m==0时 n+12.当m!=0&&n==0时 akm(m-1,1)3.当m!=0&&n!=0时 akm(m-1,akm(m,n-1))*/typedef struct Node{ int m; int n; int sum; int flag;};int AKM(int m, int n){ Node s[10.

2021-11-20 19:06:11 256

原创 栈:判断出栈合法性

#include<iostream>#include<stack>using namespace std;void Judge(int s[], int target[],int k){ stack<int>mystack; int i = 0, j = 0; int count = 0; //count用于记录遍历情况 while (i<k) { while (s[i]!=target[j]) //在入栈过程中 { mys.

2021-11-20 11:29:33 323

原创 递归:从m个数中选出k个数的全排列

#include<iostream>using namespace std;int a[100];void Combine(int m, int k,int n) //从m个数里面选出k个数{ if (m < k) return; if (k == 0) { for (int i = 0; i < n; i++) cout << a[i]; cout << '\n'; } else { //选m .

2021-11-20 10:34:35 658

原创 队:用队列解决杨辉三角问题

问题描述:输出杨辉三角的某一行#include<iostream>#include<queue>using namespace std;void YHSJ(int count){ queue<int>myqueue; myqueue.push(1); if (count == 1) { cout << myqueue.front(); return; } else { myqueue.push(1); while

2021-11-19 19:33:58 462

原创 队:包子和馒头

Description复旦大学食堂提供了精美的早餐,其中包含有包子和馒头,分别用数字0和1表示。所有取餐的学生站在一个队列里面,每一个学生要么喜欢包子要么喜欢馒头。食堂里包子和馒头的总数和学生的数量一样。所有的包子和馒头都放在一个个摞起来的笼屉里面(每个笼屉里放一个包子或一个馒头,每次只能取最顶部的笼屉),每一轮:(1)如果队列最前面的学生喜欢顶部笼屉里的早餐,那么会拿走并离开队列。(2)否则,这名学生会重新排队。这个过程一直持续到没有学生喜欢顶部笼屉的早餐为止。现在给出学生和.

2021-11-14 16:57:59 677

原创 递归:N皇后问题

#include<stdio.h>#include<iostream>using namespace std;#define N 5int number = 0;int place[N] = { 0 };//place[n]表示在第n行的place[n]列放置了皇后,便于后续输出bool flag[N]; //表示列占领,1表示可以放置(未被占领),0表示不能放置(已被占领)bool d1[2 * N - 1];//右对角线(main函数中初始化为1)bool .

2021-11-14 16:46:47 501

原创 栈:迷宫问题(多组矩阵)

#include<iostream>#include<stack>#include<vector>using namespace std;typedef struct Direction{ int intcx, intcy;};Direction direction[4] = { {0,1},{1,0},{0,-1},{-1,0} };//分别表示右、下、左、上四个方向typedef struct Node{ int x; int y; in.

2021-11-14 16:19:09 82

原创 算法:KMP算法

int BF(char S[], char T[]){ int i = 0; int j = 0; while (S[i] != '\0' && T[j] != '\0') { if (S[i] == T[j]) { i++; j++; } else { i = i - j + 1;//i和j同时回溯 j = 0; } } if (T[j] == '\0') return i - j; else return -1;.

2021-11-14 15:28:26 350

原创 链表:实现两个有序且非单调递减链表合并成一个非递增有序单链表(不能增加新结点)

#include<iostream>using namespace std;typedef struct LNode{ int data; struct LNode* next;};void CreateList(LNode* & mylist){ LNode* p, *q; mylist = (LNode*)malloc(sizeof(LNode)); mylist->next = NULL;//创建头结点 p .

2021-11-14 14:47:01 634

空空如也

空空如也

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

TA关注的人

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