摘要: 其左子树中所有结点的键值小于该结点的键值; 其右子树中所有结点的键值大于等于该结点的键值; Description 二叉搜索树或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子 树不空,则左子树上所有结点的值均小于它的根结点的值;若它的右子树不 空,则右子树上所有结点的值均大于它的根结点的值; 阅读全文
posted @ 2024-10-20 21:47 某朝 阅读(21) 评论(0) 推荐(0)
摘要: #include <stdio.h> int main() { int a=8,b=5,c=3,d=2; if (a<b<c<d) putchar('A'); else putchar('B'); printf("%d,%d,%d,%d\n",a,b,c,d); if (a=b=c) putchar 阅读全文
posted @ 2024-10-20 10:32 某朝 阅读(14) 评论(0) 推荐(0)
摘要: #Description #Input #Output #Sample Input #Sample Output #思路 阅读全文
posted @ 2024-10-19 12:56 某朝 阅读(12) 评论(0) 推荐(0)
摘要: 查找不存在的元素 左边比它小,右边比它大 阅读全文
posted @ 2024-10-18 22:44 某朝 阅读(9) 评论(0) 推荐(0)
摘要: #include <math.h> #include <iostream> #include <algorithm> #include <fstream> #include <iomanip> #include <string> #include <vector> #include <queue> 阅读全文
posted @ 2024-10-18 17:53 某朝 阅读(6) 评论(0) 推荐(0)
摘要: Description 给出一棵二叉树的中序遍历和每个节点的父节点,求这棵二叉树的先序和后 序遍历。 Input 输入第一行为一个正整数 n 表示二叉树的节点数目, 节点编号从 1 到 n,其中 1 为根节点。 第 2 行有 n 个数字, 第 i 个数字表示 i 的父亲节点。( 1 的父亲节点为 0 阅读全文
posted @ 2024-10-18 17:48 某朝 阅读(38) 评论(0) 推荐(0)
摘要: 建树 数组模拟链表(静态链表) 程序框架 1.题意及建树 2.建树及同构判别 #include <iostream> #include <cstring> // for memset using namespace std; const int N = 10; struct TreeNode { c 阅读全文
posted @ 2024-10-17 17:21 某朝 阅读(7) 评论(0) 推荐(0)
摘要: 方法1: #include <stdio.h> int main() { char str[80]; scanf("%[^\n]",str); //读到'\n'结束读取 printf("%s",str); return 0; } %[^\n]读到'\n'结束读取 %[^:]读到:结束读取 方法2: 阅读全文
posted @ 2024-10-15 23:26 某朝 阅读(94) 评论(0) 推荐(0)
摘要: 格式说明符 输出4位而不是保留4位 使用 %.4g 进行格式化,能够确保输出的有效数字为四位,并去掉不必要的后缀零 阅读全文
posted @ 2024-10-15 17:52 某朝 阅读(14) 评论(0) 推荐(0)
摘要: csdn #include <stdio.h> #include <limits.h> #include <float.h> int main() { printf("%zd %d %.15g %.15g\n", sizeof(double), DBL_DIG, DBL_MIN, DBL_MAX); 阅读全文
posted @ 2024-10-13 13:29 某朝 阅读(60) 评论(0) 推荐(0)