更新实验报告
This commit is contained in:
parent
da0755858e
commit
7123a79aa6
14
7/s3.c
14
7/s3.c
|
@ -259,6 +259,18 @@ void pt(Tree *root) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 打印二叉树
|
||||||
|
void printTree(Tree *root, int level) {
|
||||||
|
if (root == NULL)
|
||||||
|
return;
|
||||||
|
printTree(root->r, level + 1);
|
||||||
|
for (int i = 0; i < level; i++)
|
||||||
|
printf(" ");
|
||||||
|
printf("%d\n", root->val);
|
||||||
|
printTree(root->l, level + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
freopen("data.in", "r", stdin);
|
freopen("data.in", "r", stdin);
|
||||||
scanf("%d", &n);
|
scanf("%d", &n);
|
||||||
|
@ -276,6 +288,8 @@ int main() {
|
||||||
scanf("%d", &x);
|
scanf("%d", &x);
|
||||||
root = deleteNode(root, x);
|
root = deleteNode(root, x);
|
||||||
pt(root);
|
pt(root);
|
||||||
|
printTree(root, 0);
|
||||||
|
printf("----------------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue