c语言课程设计 学生管理,求助~C语言课程设计--学生上机管理

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

return 1;

}

}

p=p->next;

} while(p!=NULL);

return 0;

}

void m_exit() /*退出*/

{

int option=0;

printf("\n\n\tAre you sure to exit?\n");

printf("\n\n\t1.YES");

printf("\n\n\t2.NO\n\t");

scanf("%d",&option);

if(option==1) exit(0);

else

return;

}

void creat() /*读取como.dat内容,并创建链表a*/

{

FILE *fp;

int n=0,i,tag=0;

struct student_type temp_stud;

struct stunode_type *p1,*p2;

p1=p2=stu_head=(struct stunode_type*)malloc(sizeof(struct stunode_type));

stu_head->next=NULL;

if((fp=fopen("c:\\COMO.DAT","rb"))==NULL)/*第一次como.dat不存在,创建*/

{ tag=1;

fp=fopen("c:\\COMO.DAT","wb");

fclose(fp);

}

if(tag==1){free(p1); stu_head=NULL;return;}

fp=fopen("c:\\COMO.DAT","rb");

/*else /*读取数据,构成链表*/

fread(&n,sizeof(int),1,fp);

total=n;

for(i=0;i

{

fread(&temp_stud,sizeof(struct student_type),1,fp);

strcpy(p1->nostudent,temp_stud.nostudent);

strcpy(p1->name,temp_stud.name);

strcpy(p1->department,temp_stud.department);

p1->type=temp_stud.type;

p1->time=temp_stud.time;

if(i

{

p1=(struct stunode_type*)malloc(sizeof(struct stunode_type));

p2->next=p1;

p2=p2->next;

}

}

p2->next=NULL;

fclose(fp);

}

void save()

{

FILE *fp;

struct student_type student;

struct stunode_type *p1=stu_head;

fp=fopen("c:\\COMO.DAT","wb");

fwrite(&total,sizeof(int),1,fp);

do

{

strcpy(student.nostudent,p1->nostudent);

strcpy(student.name,p1->name);

strcpy(student.department,p1->department);

student.type=p1->type;

student.time=p1->time;

fwrite(&student,sizeof(struct student_type),1,fp);

p1=p1->next;

}

while(p1!=NULL);

fclose(fp);

}

void list_student()/*列出所有注册的学生*/

{

struct stunode_type *p=stu_head;

if(stu_head==NULL){ printf("\n\n\t the student list is NULL");return;}

printf("the all students are as follows\n");

while(p!=NULL)

{ printf("\n\n\tnostudent:%s\n",p->nostudent);

printf("\n\n\tname:%s",p->name);

printf("\n\n\tdepartment:%s",p->department);

printf("\n\n\ttime:%d",p->time);

p=p->next;

}

}

void main()

{ char option;

char tm_nostudent[5];

creat();

do

{printf("\n\t***********************************************\n");

printf("\n\n\tWELCOME TO USE JIFANG MANAGE SYSTEM\n");

printf("\n\t**********************************************\n");

printf("\n\n\t\tPlease make a choice below:");

printf("\n\t\t1.Add new student imformation");

printf("\n\t\t2.Shang Ji");

printf("\n\t\t3.Xia ji");

printf("\n\t\t4.Add Time");

printf("\n\t\t5.Search the student's imformation");

printf("\n\t\t6.List all student");

printf("\n\t\t7.Exit");

printf("\n\n\n");

printf("\tInput Your Choice:");

option=getche();

switch(option)

{ case '1': addstudent(); break;

case '2': shangji(); break;

case '3': xiaji(); break;

case '4': addtime(); break;

case '5':

{ printf("\n\n\tplease input the number of the student you want to search\n");

printf("\n\n\tnumber:");

scanf("%s",tm_nostudent);

if(!search(2,tm_nostudent)) printf("\n\n\t the student is not exist!");

break;

}

case '6': list_student();break;

case '7': m_exit(); break;

default:

printf("\n\t********************************************\n");

printf("\n\t The num should 1-7! \n");

printf("\n\t********************************************\n");

break;

}

}while(1);

}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值