学生籍贯信息记录簿设计

上传人:公**** 文档编号:563856226 上传时间:2023-11-06 格式:DOCX 页数:12 大小:23.04KB
返回 下载 相关 举报
学生籍贯信息记录簿设计_第1页
第1页 / 共12页
学生籍贯信息记录簿设计_第2页
第2页 / 共12页
学生籍贯信息记录簿设计_第3页
第3页 / 共12页
学生籍贯信息记录簿设计_第4页
第4页 / 共12页
学生籍贯信息记录簿设计_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《学生籍贯信息记录簿设计》由会员分享,可在线阅读,更多相关《学生籍贯信息记录簿设计(12页珍藏版)》请在金锄头文库上搜索。

1、学生籍贯信息记录簿设计编制一个学生籍贯信息记录簿,每个学生信息包括:学号、姓名、籍贯。具体功能:(1) 创建信息并以磁盘文件保存;(2) 读取磁盘文件并显示输出所有学生的籍贯信息;(3) 按学号或姓名查询其籍贯;(4) 按籍贯查询并输出该籍贯的所有学生;(5) 统计并生成统计报表:(6) 能添加、删除和修改学生的籍贯信息;课程设计题目设置下列题目,请学生任选一题完成。要求:(1) 采用模块化程序设计的方法。(2) 锯齿型程序书写格式。(3) 必须上机调试通过。(4) 源程序代码中有注释。#include stdio.h#include stdlib.h#includest ring.hstru

2、et addresschar name30;char street40;char city 20;char state3;char zipll;struet address *next;/*pointertonext entry */struet address *prior;/*pointertoprevious record */;struet address*start;/*pointertofirst entry in list */struet address*last;/*pointertovoidlast entry */struet address *find(char*);e

3、nt er(void),seareh(void),save(void);void load(void),lis t(v oid);void mldelete(struet address *,struet address*);void dls_store(struet address *i,struet address *start,struetaddress *last);void inputs(ehar *, ehar *, int);void display(struet address *);int menu_seleet (void);int main(void)start 二 la

4、st 二 NULL;/* initializestart and end pointers */for(;)swit eh (menu_selee t()case 1: enter ()7/*ddress */break;case 2: mldelete(&start, &last); address */ break;/*case 3: list();e list */break;/*case 4: search()dress */break;/*case 5: save();to disk */break;/*case 6: load();disk */break; case 7: exi

5、t(0);return 0;/*enter an aremove andisplay thfind an adsave listread from/* Select an operation. */int menu_select(void)char s80;int c;pri ntf( l.E ntry a name n);pri ntf (2.Dele te a name n);pri ntf (3.Lis t the file n);pri ntf (4.Search n);pri ntf (5.Save the file n);pri ntf (6.Load the file n);pr

6、i ntf (7.Qu it n);do printf (n Enter your choice:);get s(s);c = ato i(s);while(c7);return c;/* Enter names and address. */void ent er(void)struct address *info;for(;)info= (struct address *)malloc(sizeof(struet address);if (!info)printf(n out of memory);return;inp ut s(E nter name:, info-name,30);if

7、(!info-name0) break;/* stop entering */inputs(Enter street:,info-street, 40);inputs(Enter city:,info-city, 20);inputs(Enter state:,info-state, 3);inp ut s(E nter zip:,info-zip, 10);dls_s to re(in fo,&start,& las t);/* entry loop */* This function will input a string up to the length in countand will

8、prevent the string from being overrun . It will also display a prompting message. */void inputs(char *prompt,char *s, int count)char p255;do printf(prompt);fgets(p, 254,stdin);if (strlen(p) (unsigned int)count) printf (n Too Longn);while(strlen(p) (unsigned int)count);pstrlen(p)l = 0;/ remove newlin

9、e charaterst rcpy(s,p);/* Create a doubly linked list insortedorder. */void dls_store(structaddress *i./*new element */structaddress *start./*firsr element inlist */structaddress *last/*last element inlist */struct address *old,*p;if( *last = NULL)/* first element in list */i-next 二 NULL;i-prior = N

10、ULL;*last 二 i;*start 二 i;return;p = *start;/* start at top list */old = NULL;while (p)if (st rcmp(pname,iname)next;else if (p-prior)p-prior-next 二 i;i-next 二 p;i-prior = p-prior;p-prior = i;return;i-next 二 p;/* new first element */i-prior = NULL;p-prior = i;*start 二 i;return ;old-nex t 二 i;/* put on

11、 old */i-next 二 NULL;i-prior = old;*last 二 i;/* Remove an element from the list. */void mldelete(struet address *start,struet address *last)struet address *info;char s80;inputs(Enter name:,s, 30);info = find(s);if (info)if (*start 二二 info)*start 二 infonext;if(*start)(*start)- prior) = NULL;else *las

12、t 二 NULL;else infopriornext 二 infonext;if (info!=*last)infonextprior = infoprior;else*last 二 infoprior;free(info);/* return memory to system*/* Find an address. */struet address *find(char *name)struet address *info;info = start;while (info)if(!s trcmp(name,infoname)re turn info;info = info-next;/*

13、get next address */printf(Name not found. n);return NULL;/* not found */* Display the entire list. */void lis t(v oid)struet address *info;info = start;while (info)display(info);info = info-next;/* get next address */printf (n n);/* This funetion aetually prints the fields in each address.*/void display(struet address *info)pri ntf (%s n,info-name);pri ntf (%s n,info-s tree t);pri ntf (%s n,info-ei ty);pri ntf (%s n,info-s tat e);pri ntf (%s n,infozip);printf (n n);/* Look for a name in the list. */void search(void)char name40;struct address *info;printf (Enter name to

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号