Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
99756 胡晏玮 前序遍历 C++ 编译错误 0 0 MS 0 KB 707 2023-08-23 17:05:40

Tests(0/0):


#include <iostream> using namespace std; struct tree{ int data; tree left,right; }gen; void insert(int const x,tree &jied){ if(x < jied.data){ if(jied.left.data == -1) jied.left.data = x; else insert(x,jied.left); } else{ if(jied.right.data == -1) jied.right.data = x; else insert(x,jied.right); } } void qingl(tree &x,int t){ if(t == 20) return; x.data = -1; qingl(x.left,t+1); qingl(x.right,t+1); } void bianl(tree jied){ if(jied.data == -1) return; cout << jied.data << ' '; bianl(jied.left); bianl(jied.right); } int main(){ int n,k; qingl(gen,0); cin >> n >> gen.data; while(--n){ cin >> k; insert(k,gen); } bianl(gen); return 0; }


测评信息: