学生选修课程系统设计(5)

2019-03-10 15:14

第 18 页 共 28页

谢 辞 参考文献

[1] 谭浩强,C程序设计题解与上机指导(第二版),北京,清华大学出版社,2000年9月。 [2] 甘玲,解析C程序设计,北京,清华大学出版社,2007年3月。 [3] 郭翠英,《C语言课程设计案例精编》,中国水利水电出版社,2005年。 [4]黄明,梁旭,万洪莉,《C语言课程设计》,电子工业出版社,2006年。

[5] 王成端 魏先民等,《C语言程序设计实训——题解、实验、课程设计与样题》,中国水利水电出版社,2005年。

[6]盛夕清,赵阳等编著,《C语言程序设计学习指导、实验指导与课程设计》,中国水利水电出版社,2006年。

第 19 页 共 28页

源程序代码:

#include \#include \#include \#include \void prin1(); void choose();

typedef struct subjects { int num; char name[20]; char kind[10]; 附 //课程编号 //课程名称 //课程性质

第 20 页 共 28页

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=sizeof(SUB); head=tail=NULL; printf(\输入选修课程信息:\\n\ scanf(\ &stime,&ttime,&etime,&score,&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=p; tail=p; scanf(\

kind,&stime,&ttime,&etime,&score,&term); } tail->next=NULL; return head; }

void savefile() //保存文件 { SUB *p;

第 21 页 共 28页

FILE *fp; fp=fopen(\ if(fp==NULL)exit(0); printf(\课程编号 课程名称 课程性质 总学时

授课学时 实验或上机学时 学分 开课学期\\n\ for(p=head;p;p=p->next) fprintf(fp,\

p->num,p->name,p->kind,p->stime,p->ttime,p->etime,p->score,p->term); fclose(fp); printf(\创建后的信息已放入'2.txt'文件中\\n\ system(\}

void savefile1() //保存文件 { SUB *p; FILE *fp; fp=fopen(\ if(fp==NULL)exit(0); for(p=head;p;p=p->next) fprintf(fp,\

p->num,p->name,p->kind,p->stime,p->ttime,p->etime,p->score,p->term); fclose(fp); printf(\创建后的信息已放入'3.txt'文件中\\n\ system(\ }

void readfile() //阅读文件 { void *myInsert(SUB*); SUB *newSub; //新课程 int num,stime,ttime,etime; int score,term; char cname[20],kind[10],fname[20]; FILE *fp; fp=fopen(\ while(!feof(fp)) { newSub=(SUB*)malloc(sizeof(SUB)); fscanf(fp,\

&newSub->stime,&newSub->ttime,&newSub->etime,&newSub->score,&newSub->term); myInsert(newSub); } fclose(fp);

第 22 页 共 28页

}

void prin() //浏览所有课程 { SUB *ptr; head=NULL; readfile(); if(head==NULL) { printf(\ return; } printf(\课程编号 课程名称 课程性质 总学时 授课学时 实践或上机学时 学分 开课学期\\n\ for(ptr=head;ptr;ptr=ptr->next) { printf(\ ptr->kind,ptr->stime,ptr->ttime,ptr->etime,ptr->score,ptr->term); } system(\}

void prin1() //浏览所有选修课程 { SUB *ptr; FILE *fp; if((fp=fopen(\ { printf(\ choose(); } printf(\课程编号 课程名称 课程性质 总学时 授课学时 实践或上机学时 学分 开课学期\\n\ while(!feof(fp)) { ptr=(SUB*)malloc(sizeof(SUB)); fscanf(fp,\ &ptr->stime,&ptr->ttime,&ptr->etime,&ptr->score,&ptr->term); printf(\ ptr->kind,ptr->stime,ptr->ttime,ptr->etime,ptr->score,ptr->term); } fclose(fp); system(\}

void *myInsert( SUB *subj) //链表插入操作 {


学生选修课程系统设计(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:新安全生产法修正解释(附前后对照表)(最新) - 图文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: