用二叉排序树实现的将乱序输入字母按从小到大排列,无重复输出项.
#include<stdio.h>
#include<stdlib.h>
#include<strings.h>
typedef struct node{
char data;
struct node *left;
struct node *right;
}node;
/*
* 中序遍历
*/
void print_node(node *p){
if(p){
print_node(p->left);
printf("%c",p->data);
print_node(p->right);
}
}
int main(void){
node *head;
char tmp;
node *p;
/*生成头节点*/
head=(node *)malloc(sizeof(node));
if (!head){
printf("1:malloc error!\n");
return -1;
}
/*将头节点填充0*/
bzero(head,sizeof(node));
while ((tmp=getchar())!=EOF){
/*判断头节点是否为空*/
if (!head->data){