项目总结日记

   这几天终于开始做项目了,原本轻松的日子终于有了些紧迫感,这篇总结就来介绍一下我的项目和做项目的思路。

    我选择的是成绩管理系统,我有现成的五子棋,但是那个做的太拉了也没有用到多少数据结构的相关知识,所以在听到二叉搜索树这个数据结构后我就想好了要做什么那就是成绩管理系统。

    为了这次的项目,我学习了easyx来做图形页面(虽然做的很拉(悲)),还学习并实现了二叉搜索树,这里说一下我对二叉搜索树的理解,我对它的印象就三个字:真的快!,建树后的查找,每一次都相当与一次二分查找,这可比普通找快多了,还有一个让我惊讶的点就是按照中序输出的二叉搜索树可以直接将数据排列好(神奇),建立,查找,插入都很简单,但世界上没有十全十美的东西,二叉搜索树的删除可要下点功夫,附上我手敲的二叉搜索树实现代码(删除还在开发中):

#include<stdio.h>
#include<malloc.h>
struct tree{
	int data;
	struct tree *lc,*rc;
};
struct tree *head=NULL,*p,*t,*q;
int n;
void creatandadd(int x);
void dfs(struct tree *t);
int find(int x);
void Delete(int x);
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		creatandadd(x);
	}
	dfs(head);
	printf("\n");
	int x;
	scanf("%d",&x);
	printf("%d\n",find(x));
	scanf("%d",&x);
	Delete(x);
	dfs(head);
	return 0;
}
void creatandadd(int x){
	if(head==NULL){
		head=(struct tree*)malloc(sizeof(struct tree));
		head->data=x;
		head->lc=NULL;
		head->rc=NULL;
		return ;
	}else{
		struct tree *q;
		p=head;
		while(p!=NULL){
			q=p;
			if(x>p->data){
				p=p->rc;
			}else{
				p=p->lc;
			}
		}
		if(q->data>x){
		  t=(struct tree*)malloc(sizeof(struct tree));
		  t->data=x;
		  t->lc=NULL;
		  t->rc=NULL;
		  q->lc=t;
		}else{
		t=(struct tree*)malloc(sizeof(struct tree));
		  t->data=x;
		  t->lc=NULL;
		  t->rc=NULL;
			q->rc=t;
		}
	}
}
void dfs(struct tree *t){
		printf("%d ",t->data);
	if(t->lc==NULL&&t->rc==NULL){
		return ;
	}
	if(t->lc!=NULL) dfs(t->lc);
	if(t->rc!=NULL) dfs(t->rc);
}
int find(int x){
	p=head;
	int step=1;
	while(p!=NULL){
		if(p->data>x){
			p=p->lc;
			step=2*step;
			continue;
		}
		if(p->data<x){
			p=p->rc;
			step=2*step+1;
			continue;
		}
		if(p->data==x){
			return step;
		}
	}
	return -1;
}
void Delete(int x){
	p=head;
	while(p->data!=x){
		if(p->data>x){
			p=p->lc;
		}else{
			p=p->rc;
		}
	}
	if(p->lc==NULL&&p->rc==NULL){
			free(p);
	}else if(p->lc==NULL){
		q=p;
		p=p->rc;
		free(q);
	}else if(p->rc==NULL){
		q=p;
		p=p->lc;
		free(q);
	}
}

最后说一下我的项目思路,先利用easyx做出主页面再结合文件操作和二叉搜索树去实现比较高效的查找与更改,最后带上我现在的项目进程:

这简单低奢(垃圾)的主页面,

 

 目前已完成成绩的录入与修改。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值