All pastes #465833 Raw Edit

Someone

public c v1 · immutable
#465833 ·published 2007-04-30 17:01 UTC
rendered paste body
#include<stdio.h>#include<stdlib.h>#include<conio.h>struct node{struct node *left;struct node *right;int val;};//void cons(struct node*, int);//void traverse(struct node *);void cons(struct node **h, int val){	//struct node *p = *h;	if(*h == NULL)	{		*h = (struct node *)malloc(sizeof(struct node));		(*h)->val = val;		(*h)->left = (*h)->right = NULL;	}	else	{		if(val < (*h)->val)			cons(&((*h)->left), val);		else if(val > (*h)->val)			cons(&((*h)->right), val);	}}void traverse(struct node *h){	struct node *p = h;	if(p != NULL)	{		traverse(p->left);		printf("%d...",p->val);		traverse(p->right);	}}int main(){	clrscr();	struct node *head = NULL;	int array[] = {1,5,6,2,9,4,7};	int i;	for(i = 0;i < 7;i++)		cons(&head, array[i]);	printf("%d..",head->val);	traverse(head);	return 0;}