摘要: step 1: 求两个数组的并集放到d中,并用vis数组表示这个元素是否在d数组中 int n,m,once=1; scanf("%d", &n); ifor(i, 0, n-1) { scanf("%d", &a[i]); } scanf("%d", &m); ifor(i, 0, m-1) { 阅读全文
posted @ 2022-11-19 10:52 noob-lian 阅读(275) 评论(0) 推荐(0)
摘要: 后序非递归遍历,需要加标记,还需要对有右子树的节点进行两次入栈操作,这是不同的 void InorderTraversal(BinTree BT) { if ( !BT ) return; BinTree tt = BT; Stack s = CreateStack(); while ( tt || 阅读全文
posted @ 2022-11-02 00:27 noob-lian 阅读(23) 评论(0) 推荐(0)
摘要: 1.ctrl + k +f:非强制的,自己写的代码中自己调整的空格不能格式化 2.ctrl + K +d:强制的 阅读全文
posted @ 2022-11-01 14:56 noob-lian 阅读(1957) 评论(0) 推荐(0)
摘要: 题目: 样例输入: 8 1 - - - 0 - 2 7 - - - - 5 - 4 6 样例输出:1 4 5 想法:记录每个节点的左右节点,在操作 tuple<int, int> das[100]; //储存节点为i的左节点,右节点 bool vis1[20];//判断某个节点是否有father,没 阅读全文
posted @ 2022-11-01 01:50 noob-lian 阅读(86) 评论(0) 推荐(0)
摘要: int n; array<int, 100>sav; //后序遍历 :左 右 根 // void f(int m) { if ( m > n ) return; f(2 * m);//先读入左节点 f((2 * m + 1));//读入右节点 cin >>sav[m];//读入根节点 } int m 阅读全文
posted @ 2022-11-01 01:40 noob-lian 阅读(19) 评论(0) 推荐(0)
摘要: 核心:完全二叉树第i个节点的左节点,对应的下标一定是2*i,右节点一定是2*i+1。 用num表示这个节点应该有的下标(虽然不用数组储存,以1开始),如果以构建完全二叉树的方式去构建树。若建树过程中,num大于节点数n,则不是完全二叉搜索树,否则是; 搜索树的构建: int n; int cnt = 阅读全文
posted @ 2022-11-01 01:35 noob-lian 阅读(68) 评论(0) 推荐(0)
摘要: //中序遍历 void InorderTraversal( BinTree BT ) { if(BT) { InorderTraversal(BT->Left); printf(" %c",BT->Data); InorderTraversal(BT->Right); } } //先序遍历 void 阅读全文
posted @ 2022-10-31 21:51 noob-lian 阅读(43) 评论(0) 推荐(0)
摘要: #define _SILENCE_CXX20_CISO646_REMOVED_WARNING #pragma warning(disable : 4996) 阅读全文
posted @ 2022-10-31 20:15 noob-lian 阅读(202) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; struct waimai { char a[100]; int weight; int hao; int price; }en[150]; int i; int main() { bool pan(waimai a, 阅读全文
posted @ 2022-04-30 11:29 noob-lian 阅读(39) 评论(0) 推荐(0)
摘要: C 和 C++ 中的 void 指针之间的区别? 看以下例子; voidp; chars; p=s; s=p; //this is wrong ,should do s=(char*)p; 即是 s=p; //this is wrong ,should do s=(char*)p; 在 C++ 中, 阅读全文
posted @ 2022-03-31 20:18 noob-lian 阅读(22) 评论(0) 推荐(0)
Language: