当前位置:首页 > C语言实习设计报告(学生公寓管理管理系统)
printf(\ scanf(\ printf(\ scanf(\
printf(\ scanf(\
printf(\
scanf(\
p2->next=p1; /*将新结点连到表尾*/ p2=p1; /*p2指向新的表尾*/ }
p2->next=NULL; head=head->next; }
save_message(head); /*将输入的数据存入文件*/ return head; }
/*输入模块*/ input_message() {
clrscr(); h=creat();
printf(\ press any key to the main meue!!!!\\n\ bioskey(0); }
/*读取信息*/ read_message()
{ struct stud *p1,*p2;
h=p1=(struct stud*)malloc(N); /*为了p1申请存储空间,并指向首结点*/ if((fp=fopen(\
{ printf(\ There is no data for the monent!\\n\ return; }
if(fread(p1,N,1,fp)!=1) return; /*先向p1读入一个数据,若不能读,返回*/ while(1)
{ p2=(struct stud*)malloc(N); /*为了p2申请存储空间*/ if(fread(p2,N,1,fp)!=1) break; p1->next=p2; p1=p2; }
fclose(fp); bioskey(0);
}
/*输出模块*/
output_message(struct stud *p) { p=h; clrscr();
if(p==NULL)
printf(\ There is no datas right now!\\n\
printf(\ name sex age major grade class building floor dormitary\\n\\n\ while(p!=NULL) {
printf(\or,p->grade,p->classes,p->building,p->floor,p->dormitary); p=p->next; }
printf(\ press any key to the main meue!!!!\\n\ bioskey(0); }
/*删除学生信息*/
del_message(struct stud *h) { int num;
struct stud *p,*p0; clrscr();
if(h==NULL) return 0;
printf(\ Please input the number who you what to delete?\\n\ scanf(\ p0=h;
if(p0->num==num) { h=p0->next;
free(p0); /*若首结点是所要删除的数据,则释放首结点*/
return 1; }
p=p0->next; while(p!=NULL) { if(p->num==num) { p0->next=p->next; free(p); return 1; } p0=p;
p=p->next; }
return 0; }
/*修改学生信息*/ revise_message() { int num1,choice; struct stud *p0; clrscr();
printf(\ Please input the number who you what to revise:\\n\ scanf(\ clrscr();
p0=h; /*将头结点赋给p0*/ do
{ if(p0->num==num1)
{ printf(\ Which you what to revise?\\n\ printf(\ 1.number\\n\ printf(\ 2.name\\n\ printf(\ 3.sex\\n\ printf(\ 4.age\\n\ printf(\ 5.major\\n\ printf(\ 6.grade\\n\ printf(\ 7.class\\n\ printf(\ 8.building\\n\ printf(\ 9.floor\\n\
printf(\ 10.dormiatry\\n\ scanf(\ switch(choice)
{ case 1:printf(\ Input the new number:\\n\ scanf(\
case 2:printf(\ Input the new name:\\n\ scanf(\
case 3:printf(\ Input the new sex:\\n\ scanf(\
case 4:printf(\ Input the new age:\\n\ scanf(\
case 5:printf(\ Input the new major:\\n\ scanf(\
case 6:printf(\ Input the new grade:\\n\ scanf(\
case 7:printf(\ Input the new class:\\n\ scanf(\
case 8:printf(\ Input the new building:\\n\
scanf(\
case 9:printf(\ Input the new floor:\\n\ scanf(\
case 10:printf(\ Input the new dormitary:\\n\ scanf(\ }
break; }
else p0=p0->next; }while(p0!=NULL); }
/*插入学生信息*/
insert_message(struct stud *h) { struct stud *p,*p0;
p=(struct stud *)malloc(N); clrscr();
printf(\ scanf(\ printf(\ scanf(\
printf(\ scanf(\
printf(\ scanf(\
printf(\ scanf(\
printf(\ scanf(\
printf(\ scanf(\ p->next=NULL; if(h==NULL) { h=p; return 1; } p0=h;
if((p0->num)>(p->num)) /*按学号顺序插入*/ { p->next=h; h=p; return 1; }
while((p0->next)!=NULL&&(p0->next->num)<(p->num)) p0=p0->next;
共分享92篇相关文档