有关c语言编程问题。。。

#include<stdio.h>
#include<malloc.h>
typedef struct node{
	int data;
	struct node* left;
	struct node* right;
}Node;
typedef struct {
	Node* root;
}Tree;
typedef struct LNode{
	struct node* nn;
	struct node* next;
}; 
typedef struct Queue{
	struct LNode* head;
	struct LNode* tail;
};
void insert(Tree* tree,int value);
void inorder(Node* node);
bool IsEmpty(Tree* tree);
void CengXu(Tree* tree);
Queue* CreatQueue();
void IsQueueEmpty(Queue* Que,Node* N);
Node* Del(Queue* Que);
bool IsQueueEmpty(Queue* Que);
void InsertQueue(Queue* Que,Node* N);
int main(){
	Tree tree;
	tree.root=NULL;
	int n=3,a[3]={1,2,3};

	for(int i=0;i<n;i++){
		insert(&tree,a[i]);
	}
	if(tree.root==NULL) printf("OK\n");
	printf("Inorder Output the Tree:");
	inorder(tree.root);
	//printf("GetElement the Tree: ");
	//GetElement(&tree);
	printf("CengXu the Tree: ");
	CengXu(&tree);
	getchar();
	return 0;
}
void insert(Tree* tree,int value){
	Node* node=(Node*)malloc(sizeof(Node));
    node->data=value;
    node->left=NULL;
    node->right=NULL;
    if(tree->root==NULL){
       tree->root=node;
	}
	else{
		Node* temp=tree->root;
		while(temp!=NULL){
			if(value<temp->data){
				if(temp->left==NULL){
					temp->left=node;
					return;
				}
				else{
					temp=temp->left;
				}
			}
			else{
				if(temp->right==NULL){
					temp->right=node;
					return;
				}
				else{
					temp=temp->right;
				}
			}
		}	
	}

	return;
}
void inorder(Node* node){
	if(node!=NULL){
		inorder(node->left);
		printf("%d ",node->data);
		inorder(node->right);
	}
	printf("\n");
}
bool IsEmpty(Tree* tree){
	if(tree->root==NULL) return true;
	else return false;
} 
void CengXu(Tree* tree){
	if(tree->root==NULL) return; 
	Queue* Que;
	Que=CreatQueue();
	Node* T;
	T=tree->root;
	InsertQueue(Que,T);
	printf("csre1 ok\n");
	while(Que->tail-=NULL){
		printf("cre1 ok\n");
    T=Del(Que);
    printf("%d ",T->data);
    if(T->left!=NULL) InsertQueue(Que,T->left);
    if(T->right!=NULL) InsertQueue(Que,T->right);
	}
	printf("\n");
}
Node* Del(Queue* Que){
	if(IsQueueEmpty(Que)) return NULL;
	else if(Que->head->next==Que->tail->nn){
		LNode* LL;
		LL=Que->tail;
		Que->head->next=Que->tail->nn;
		Que->tail=NULL;
		return LL->nn;
	}
	else{
		LNode* LL;
		LL->next=Que->head->next;
		Que->head->next=LL->next;
		return LL->nn;
	}
}
void InsertQueue(Queue* Que,Node* N){
	printf("1111111111111111111111111111111\n");
	LNode *LL=(LNode*)malloc(sizeof(LNode));
	printf("22222222222222222222222222222222222\n");
	LL->nn=N;
    LL->next=NULL; 
	if(IsQueueEmpty(Que)){
	Que->head->next=LL->nn;
	Que->tail=LL;
	printf("Insert is ok1");	
	}
	else{
		Que->tail->next=LL->nn;
		Que->tail=LL;
		printf("Insert is ok2");
	}
}
bool IsQueueEmpty(Queue* Que){
	if(Que->head->next==NULL) return true;
	else return false;
}
Queue* CreatQueue(){
	Queue* Q;
	Q=(Queue*)malloc(sizeof(Queue));
	Q->tail->nn=NULL;
	Q->head->next=Q->tail->nn;
	Q->tail->next=NULL;
}

我编的这个程序不知道为什么运行到图片 蓝色框 这个函数里面  就运行不了了。。。

求大佬 指导,小弟五体投地。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值