//file1.h
#include<stdio.h>
#include<stdlib.h>
typedef char
ElemType;
/*---------------二叉树结构类型定义---------------*/
typedef struct BNode
{
int Desent;/*存放该结点子孙的个数*/
ElemType Data;/*data域*/
struct BNode *Lson,*Rson;
/*左右孩子指针*/
}BNode,*BinTree;
/*-------------------------------------------------------------*/
void CreateBinTree(BinTree *T)
{
/*以加入节点的先序PreOrder序列输入,构造二叉链表 */
ElemType ch;
scanf("%c",&ch);
if(ch=='#')*T=NULL;/*读入0时,将相应节点置空*/
else{
*T=(BinTree *)malloc(sizeof(BNode));
(*T)->Data=ch;
CreateBinTree(&(*T)->Lson);
CreateBinTree(&(*T)->Rson);
}
}
/*-------------------------------------------------------------*/
void Visit(ElemType e)
{
printf("%c ",e);
}
/*---------------------计算总结点数----------------------------*/
int NUM(BinTree bt)
{
if (bt==NULL) return 0;
/*递归调用的结束条件*/
else return NUM(bt->Lson)+NUM(bt->Rson)+1;
}
/*-----------------------计算各结点子孙数----------------------*/
void CountDes(BinTree bt)
{
if(bt==NULL)bt->Desent=0;
else
{
int k=NUM(bt);
bt->Desent=k-1;
CountDes(bt->Lson);
CountDes(bt->Rson);
}
}
/*-------------------先序输出各结点值及子孙数------------------*/
void PreOrderOut(BinTree bt)
{
if(bt==NULL)return;
Visit(bt->Data);
printf("%d\n",bt->Desent);
PreOrderOut(bt->Lson);
PreOrderOut(bt->Rson);
}
/*--------------------------------------------------------------*/
main()
{
BinTree
t;
CreateBinTree(&t);
CountDes(t);
PreOrderOut(t);
getch();
}
//file2.c
#include"file1.h"
............//请问这里加什么起屏蔽作用的语句
/*---------------二叉树结构类型定义---------------*/
typedef struct BNode
{
ElemType Data;/*data域*/
struct BNode *Lson,*Rson;
/*左右孩子指针*/
}BNode,*BinTree;
......
//file1.h中定义了一个结构,file2.c中又定义了一个结构体名相同的结构,如何才能不发生冲突,前提是不改结构体名