标签:ace clu val main || treenode uil root names
#include <bits/stdc++.h> using namespace std; int a[105],t=0; struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; }; TreeNode* build(TreeNode * &root,int g) { if(g>t||a[g]==0) { root=NULL; return root; } root=(TreeNode*)malloc(sizeof(TreeNode)); root->val=a[g]; build(root->left,2*g); build(root->right,2*g+1); return root; } int main() { int n,m,i,j,k; while(cin>>k,k!=-1) a[++t]=k; TreeNode *root; root=build(root,1); cout<<k<<endl; }
标签:ace clu val main || treenode uil root names
原文地址:https://www.cnblogs.com/ww123/p/8999430.html