- 博客(13)
- 收藏
- 关注
原创 KMP算法4
#include<stdio.h>#include<string.h>//计算next函数值int get_next(char *T,int *next){ int i,j; i=1; next[1]=0; j=0; while(i<strlen(T)) { if(j==0||T[i-1]==T[j-1]) { i++; j++; next[i]=j; } else { j=next[j]; .
2021-11-23 17:15:43 321
原创 进制转换1
#include<malloc.h>#include<math.h>#include<stdio.h>#include<stdlib.h>#include<iostream>#include<process.h>#define maxsize 100typedef struct { int *top; int *base; int stacksize;}sqStack;void initStack(sqSta.
2021-11-19 09:33:05 61
原创 回文数判断
#include <bits/stdc++.h>#include<stdio.h>#include<string.h>#define intsize 100typedef struct { int *base; int *top; int stacksize; }sqstack; int initstack(sqstack &S,int m){ S.base=new int[m]; if(!S.base) return -1; S.t.
2021-11-19 09:31:49 99
原创 斐波那契非递归
#include<stdio.h>#include<time.h>//斐波那契非递归int Fib2(int n){ if(n==1||n==2) return 1; int f1,f2,f3; f1=1;f2=1; for(int i=3;i<=n;i++){ f3=f1+f2; f1=f2; f2=f3; } return f3;}int main(){ int n; int start,end; printf("请输入一个数.
2021-11-19 09:30:44 67
原创 斐波那契1
#include<stdio.h>#include<time.h>//斐波那契递归long long Fib(int n){ if(n==1||n==2) return 1; else return Fib(n-1)+Fib(n-2); } int main(){ int n; int start,end; printf("请输入一个数:"); scanf("%d",&n); //start = clock(); int a; a=Fi.
2021-11-19 09:29:35 48
原创 队列实现约瑟夫环
#include<stdio.h>#include<stdlib.h> int MAXQSIZE; //循环队列长度为(MAXQSIZE-1)typedef struct{ //定义队列 int*base; int front; int rear;}SqQueue;void init(SqQueue&L) //创建循环队列并初始化 { L.base=(int*)malloc(MAXQSIZE*sizeof(int));.
2021-11-19 09:26:51 1178
原创 递归实现约瑟夫环
#include<stdio.h> int Josephus(int sum,int m,int n) { if(n==1) return (sum+m-1)%m; else return (Josephus(sum-1,m,n-1)+m)%sum; } int main(void) { int sum,n,m; printf("请输入总人数,要排除的数和实现次数:");.
2021-11-19 09:24:31 207
原创 单链表的基本操作
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> using namespace std; #define Status int #define ElemType int //单链表结点数据结构 typedef struct LNode { ElemType data;//数据域 struct LN.
2021-11-19 09:23:07 60
原创 KMP算法
BF算法:暴力破解法,速度慢,使用穷举法思想,容易理解KMP算法相对BF算法,速度有了提高,因为主串的索引i不需要回溯。比较两种算法,匹配成功后的移动次数。
2021-11-19 09:19:31 41
原创 n的阶乘1
#include<stdio.h>#include<time.h>////n!//long long Fact(int n){//// if(n==0) return 1;// else return n*Fact(n-1);////}////斐波那契递归//long long Fib(int n)//{// int b;// if(n==1||n==2) b= 1;// else b=Fib(n-1)+Fib(n-2);// printf(".
2021-11-19 09:18:07 214
原创 遍历二叉树
#include<stdio.h>#include<stdlib.h>typedef char elemtype;typedef struct BiTNode{ char data; struct BiTNode *lchild,*rchild;}BiTNode,*BiTree; //FCA##DB###EH##GM### BiTree CreatBiTree() //3{ BiTree T; char c; scanf("%c",&c); if.
2021-11-19 08:03:08 46
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人