上机题3
来源:互联网 发布:科易数据防泄漏系统 编辑:程序博客网 时间:2024/04/28 08:38
#include <stdio.h>
typedef struct node
{
int data;
struct node *left;
struct node *right;
}node;
void print(node *p)
{
if(p!=NULL)
{
print(p->left);
printf("%d/n",p->data);
print(p->right);
}
}
void main()
{
int n;
node *head,*f,*p,*q;
scanf("%d",&n);
head=(node *)malloc(sizeof(node));
head->data =n;
head->left =NULL;
head->right =NULL;
scanf("%d",&n);
while(n!=-1)
{
p=(node *)malloc(sizeof(node));
p->data =n;
p->left=NULL;
p->right =NULL;
q=head;
f=q;
while(q!=NULL)
{
if(n<q->data )
{
f=q;
q=q->left ;
continue;
}
if(n>q->data )
{
f=q;
q=q->right ;
continue;
}
}
if(n<f->data ) f->left =p;
if(n>f->data ) f->right =p;
scanf("%d",&n);
}
print(head);
}
- 上机题3
- 上机题
- 上机3
- 上机3
- 上机3
- 华为2011上机笔试题3
- 上机笔试题3及程序源码
- c# MyBank 上机题1 2 3
- c#第三章上机题2-3
- 上机题2
- 某公司上机题
- 汇编上机题集锦
- c++上机实践题
- 一道上机题
- 一道上机题
- 上机练习题参考题
- 华为Java上机题
- 迅雷Java上机题
- 使用jgraph的“Hello world!"
- 上机题2
- Java的事件模型
- ORACLE 中常用的格式化函数
- 量子计算机(QUANTUM COMPUTER)
- 上机题3
- 关于利用 eclipse+CDT 进行嵌入式平台开发的调研
- 最近一项目领导让改成C++ builder的
- 为了自已的家人,Delphi水平猛进中.....
- 在ASP.NET中值得注意的两个地方
- 散分求jtidy.jar
- 通过reflect中得到数组类型
- 求jtidy.jar
- 网络病毒源的排查(2005年3月22日维护记录)