commit b3737a410a5a4ed1d2fd949c9f048d9120b4f6c6 Author: 18783852161 <18783852161@163.com> Date: Tue Jan 8 19:46:44 2019 +0800 first commit diff --git a/学生选修课程系统设计.h b/学生选修课程系统设计.h new file mode 100644 index 0000000..9c7e3b0 --- /dev/null +++ b/学生选修课程系统设计.h @@ -0,0 +1,86 @@ +#include "stdio.h" +#include "string.h" +#include "stdlib.h" +#include "malloc.h" +void prin1(); +void choose(); +typedef struct subjects +{ + int num; + char name[20]; + char kind[10]; + int stime; + int ttime; + int etime; + int score; + int term; + struct subjects *next; +}sub; +sub *head=NULL; +sub *create_form() +{ + sub *head,*tail,*p; + int num,stime,ttime; + int etime,score,term; + char name[20],kind[10]; + int size=tail==NULL; + printf("ÊäÈëÑ¡Ð޿γÌÐÅÏ¢:\n"); + scanf("%d%s%s%d%d%d%d%d",&num,&name,&kind,&stime,&ttime,&etime,&term); + while(num!=0) + { + p=(sub *)malloc(size); + p->num=num; + strcpy(p->name,name); + strcpy(p->kind,kind); + p->stime=stime; + p->ttime=ttime; + p->etime=etime; + p->score=score; + p->term=term; + if(head==NULL) + head=p; + else + tail->next=NULL; + tail=p; + scanf("%d%s%s%d%d%d%d%d",&num,&name,&kind,&stime,&ttime,&etime,&score,&term); + } + tail->next=NULL; + return head; +} +void savefile1() +{ + sub *p; + FILE *fp; + fp=fopen("3.txt","w"); + if(fp==NULL)exit(0); + for(p=head;p;p->next) + fprintf(fp,"%5d%12d%9d%11d%11d%7d\n",p->num,p->name,p->kind,p->stime,p->ttime,p->etime,p->score,p->term); + fclose(fp); + printf("´´½¨ºóµÄÐÅÏ¢ÒÑ·ÅÈë'3.txt'ÎļþÖÐ\n"); + system("pause"); +} +void readfile() +{ + void *myInsert(sub*); + sub *newSub; + int num,stime,ttime,etime; + int score,term; + char c,name[20],kind[10],fname[20]; + FILE *fp; + fp=fopen("3.txt","r"); + while(!feof(fp)) + { + newSub=(sub*)malloc(sizeof(sub)); + fscanf(fp,"%d%s%s%d%d%d%d%d\n",&newSub->num,&newSub->name,&newSub->kind,&newSub->stime,&newSub->ttime,&newSub->etime,&newSub->score,&newSub->term); + myInsert(newSub); + } + fclose(fp); +} +void prin() +{ + sub *ptr; + head=NULL; + readfile(); + printf("¿Î³Ì±àºÅ ¿Î³ÌÃû³Æ ¿Î³ÌÐÔÖÊ ×Üѧʱ ÊÚ¿Îѧʱ ʵ¼ù»òÉÏ»úѧʱ ѧ·Ö ¿ªÑ§Ñ§ÆÚ\n"); +} +