- 博客(31)
- 收藏
- 关注
原创 C++线索二叉树-插入和删除用非递归算法
template <typename Comparable>class ThreadTree{private: struct ThreadNode //线索二叉树结点定义 { Comparable element; ThreadNode* left, * right; int ltag, rtag; //0表示指向左右孩子,1表示指向前驱后继结点 explicit ThreadNode(const Comparable& el = Comparable{}, T
2022-05-31 00:58:30 292
原创 C++线索二叉树类模板,添加和删除用递归算法
template <typename Comparable>class ThreadTree{private: struct ThreadNode //线索二叉树结点定义 { Comparable element; ThreadNode* left, * right; int ltag, rtag; //0表示指向左右孩子,1表示指向前驱后继结点 explicit ThreadNode(const Comparable& el = Comparable{}, T
2022-05-30 22:29:27 194
原创 二叉搜搜索树-懒惰删除
#include <algorithm>#include <iostream>#include <stack>template <typename Comparable>class BSTree{private: struct BinaryNode { Comparable element; bool deleted; //增加bool变量,记录元素是否删除。 BinaryNode* left, * right; expli
2022-05-26 17:52:48 82
原创 【Set实现-AVL树(增加双亲及前驱和后继结点,私有数据增加头尾结点】
Set.h#include <algorithm>#include <iostream>#include <stack>#include <utility>template <typename Comparable>class Set{private: struct BinaryNode //结点定义 { Comparable element; BinaryNode* left, * right; Binary
2022-05-26 01:39:24 145
原创 queue的vector实现(可动态增长)
template <typename Object>class Queue{private: vector<Object> data; int rear; int head;public: Queue() : data(5), rear(0), head(0) { } bool empty() const { return rear == head; } int size() const { return (rear - head + data
2022-05-23 22:54:12 307
原创 AVL树-非递归算法(增加parent结点)
template <typename Comparable>class AvlTree{private: struct AvlNode { Comparable element; AvlNode* parent; AvlNode* left; AvlNode* right; int height; AvlNode(const Comparable& ele, AvlNode* lt, AvlNode* rt, AvlNode* pt, int h = 0
2022-05-22 11:58:45 136 1
原创 C++二叉搜索树(非递归算法)
#include <iostream>#include <stack>#include <queue>#include <algorithm>using namespace std;template <typename Comparable>class BinarySearchTree{public: BinarySearchTree() { root = nullptr; } BinarySearchTree(co
2022-05-20 23:48:33 131
原创 后缀表达式转化为中缀表达式
#include "Header.h"#include "stock00.h"vector<string> postfix_to_infix(const vector<string>& postfix){ stack<string> numstack; string a, b; for (const auto& x : postfix) { if (isdigit(x[0])) { numstack.push(x); }
2022-05-17 14:21:20 626
原创 c++,中缀表达式转为后缀表达式
int in_stack_priority(char c){ int ret; switch (c) { case '+': case '-': ret = 2;break; case '*': case '/': ret = 4; break; case '(': ret = 0; break; } return ret;}int out_stack_priority(char c){ int ret; switch (c) { case '+': case '-'
2022-05-17 11:07:02 327
原创 静态链表【可直接编译运行】
# include <stdio.h># include <string.h># define MAXSIZE 1000typedef struct SLinkList{ int data; int cur;}component, SLinklist[MAXSIZE];int LocateElem_SL(SLinklist S, int e){ int i = S[0].cur; while (i && S[i].data != e) {
2022-01-28 10:59:18 668
原创 n个人围成,从1个人顺序报号1,2,3。凡报到3者退出圈子,最后只剩下一个人,输出这个人的序号。
# include <stdio.h># include <math.h># include <string.h># include <stdlib.h>typedef struct Lnode{ int data; struct Lnode* next;}Lnode, * Linklist;void main(){ Linklist tailinsert(Linklist L); int length(Linklist L); L
2022-01-20 22:04:13 619
原创 统计字符串有多个整数并输出
# include <stdio.h># include <math.h># include <string.h># include <stdlib.h>void main(){ char c[1000]; puts("input a string"); gets(c); int a[1000], n = 0; void find_num(int*, char*); for (int i = 0; i < 1000; i++)
2022-01-19 21:09:25 425
原创 将字符串最长单词输出
# include <stdio.h># include <math.h># include <string.h> int main(){ void function(void); function(); return 0;} void function(void) { char c[200]; void input_longest_word(char c[]); puts("input a string:"); gets(c);
2022-01-13 15:54:50 183
原创 特征值和差公式证明
证明行列式特征值和积![graph TD;A-->B;B-->C;](https://img-blog.csdnimg.cn/2021053115074947.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MjU2NDM1MQ==,size_16,color_FFFFFF,t_70)...
2021-05-31 15:08:01 265
原创 求最大公约数和最小公倍数(辗转相除法)
辗转相除法的推出主要是利用了a,b的最小公倍数和a, b + na( n为整数) 的公倍数相等#include <stdio.h>int main(){ int a, b, l, h; int gcd( int x, int y);//求最大公约数 int lcm( int x, int y, int h);//求最小公倍数 puts("输入a, b的值:"); scanf("%d%d", &a, &b); h = gcd( a, b);
2021-05-08 23:11:09 79
原创 求2/1, 3/2, 5/3,8/5, 13/8, 21/13 的前二十项之和
#include <stdio.h>void main(){ double fo, ft, s, i; fo = 1.0, ft =2.0; s = 0.0; for( i = 1.0; i <= 10.0; i ++) { fo = fo + ft; ft = fo + ft; s += fo / ( ft- fo) + ( ft - fo) / ( 2 * fo - ft); } printf("数列前二十项之和为:%16.10lf", s);
2021-03-24 23:49:57 229
原创 C语言 - 输出完数
#include <stdio.h>main(){ int i, j, sn; for( i = 1; i <= 1000; i ++) { for( j = 1, sn = 0; j <= i-1; j ++) { if( i % j == 0) { sn += j; } } if( sn == i ) { printf("%d its factors are ",i); for( j = 1; j <= i
2021-03-23 23:48:49 1706 1
javaweb登录模块 , 双token + redis(防止多设备登录)
2022-11-14
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人