一. 设计题目
利用文件和链表建立了一个简单的学生通讯录管理程序。要求能够查找、添加、修改、删除学生信息。
二. 设计思想
程序设计采用模块化设计,分为四个部分。如下图
每个学生的记录包括以下数据项:
一。学生证,2。名字,3。宿舍,4号。**
整个系统由若干个函数构成,每个函数实现一个具体的功能。本程序定义了8个函数,函数如下:
struct stu *creatstudent(struct stu *h); 建立一个链表
struct stu *modifystudent(struct stu *h); 修改学生信息
struct stu *addstudent(struct stu *h); 添加学生信息
struct stu *searchstudent(struct stu *h); 查找学生信息
struct stu *deletestudent(struct stu *h); 删除学生信息
struct stu *recordstudent(struct stu *h); 保存学生信息
struct stu *getrecord(struct stu *h); 读取学生信息
void printstudent(struct stu *h显示所有学生信息
系统流程图
三. 程序清单
#include
#include
#include
#include
struct stu
/*每次执行后,返回主菜单*/
};主函数部分*/
/*函数自定义部分*/
struct stu *creatstudent(struct stu *h)
; if(h==null)
h=p2;
else p1->next=p2;
p1=p2;
int a;
printf("do you want to add another one?(yes,1)(no.0)n");/*按1添加下一条*/
scanf("%d",&a);
while(a==1)
printstudent(h);
return h;
}void printstudent(struct stu *h)
{clrscr();
struct stu * temp;
temp=h;
printf("the student record isn:");
while(temp!=null)
{printf("id:%s ",temp->id);
printf("name:%s ",temp->name);