




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#include <stdio.h>#include <stdlib.h> #include <string.h> typedef struct subjects int num; char name20; char kind10; int stime; int ttime; int etime; int score; int term; struct subjects *next;SUB; SUB *create_form() SUB *head,*tail,*p; int num,stime,ttime; int etime,score,term; ch
2、ar name20,kind10; int size=sizeof(SUB);head=tail=NULL;printf("输入选修课程信息:n"); scanf("%d %s %s %d %d %d %d %d",&num,&name,&kind,&stime,&ttime,&etime,&score,&term); while(num!=0) p=(SUB *)malloc(size); p->num=num; strcpy(p->name,name); strcpy(p-&
3、gt;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("%d %s %s %d %d %d %d %d",&num,&name,&kind,&stime,&ttime,&etime,&score,&term); tail->next
4、=NULL; return head; void savefile(SUB *head) SUB *p; FILE *fp; fp=fopen("subjects.txt","w");fprintf(fp,"课程编号 课程名称 课程性质 总学时 授课学时 实验或上机学时 学分 开课学期n"); for(p=head;p;p=p->next)fprintf(fp,"%5d%12s%9s%9d%9d%11d%11d%7dn",p->num,p->name,p->kind,p->stime,
5、p->ttime,p->etime,p->score,p->term); fclose(fp); void savefileadd(SUB *head) SUB *p; FILE *fp; fp=fopen("subjectsadd.txt","w"); fprintf(fp,"课程编号 课程名称 课程性质 总学时 授课学时 实验或上机学时 学分 开课学期n"); for(p=head;p;p=p->next) fprintf(fp,"%5d%12s%9s%9d%9d%11d%11d%7dn&q
6、uot;,p->num,p->name,p->kind,p->stime,p->ttime,p->etime,p->score,p->term); fclose(fp); void savefiledel(SUB *head) SUB *p; FILE *fp; fp=fopen("subjectsdel.txt","w"); fprintf(fp,"课程编号 课程名称 课程性质 总学时 授课学时 实验或上机学时 学分 开课学期n"); for(p=head;p;p=p->next
7、) fprintf(fp,"%5d%12s%9s%9d%9d%11d%11d%7dn",p->num,p->name,p->kind,p->stime,p->ttime,p->etime,p->score,p->term); fclose(fp);void prin(SUB *head) SUB *ptr; if(head=NULL) printf("没有此门课程记录!n"); return; printf("课程编号 课程名称 课程性质 总学时 授课学时 实践或上机学时 学分 开课学期n&quo
8、t;); for(ptr=head;ptr;ptr=ptr->next) printf("%5d%12s%9s%9d%9d%11d%11d%7dn",ptr->num,ptr->name,ptr->kind,ptr->stime,ptr->ttime,ptr->etime,ptr->score,ptr->term);void search(SUB *head) int a,num; int t=1; char type10; char ch='a',ch1; SUB *ptr; while(ch!=
9、9; ') printf("若要按课程性质查找请输入1,若要按学分查找请输入2:n"); scanf("%d",&a); switch(a) case 1:printf("请输入要查找的课程的性质:n"); scanf("%s",type); printf("课程编号 课程名称 课程性质 总学时 授课学时 实践或上机学时 学分 开课学期n"); for(ptr=head;ptr;ptr=ptr->next) if(strcmp(type,ptr->kind)=0) p
10、rintf("%5d%12s%9s%9d%9d%11d%11d%7dn",ptr->num,ptr->name,ptr->kind,ptr->stime,ptr->ttime,ptr->etime,ptr->score,ptr->term); t=0; if(t) printf("未找到!n"); t=1; break; case 2:printf("输入要查找的课程的学分n"); scanf("%d",&num); printf("课程编号 课程名
11、称 课程性质 总学时 授课学时 实践或上机学时 学分 开课学期n"); for(ptr=head;ptr;ptr=ptr->next) if(ptr->score=num) printf("%5d%12s%9s%9d%9d%11d%11d%7dn",ptr->num,ptr->name,ptr->kind,ptr->stime,ptr->ttime,ptr->etime,ptr->score,ptr->term); t=0; if(t) printf("未找到!n"); t=1; pr
12、intf("继续查找请按回车键,结束请按空格键:n"); ch1=getchar(); /将回车键赋给CH1,否则CASE里面最后输入的回车键会赋给CH,因此用CH1填补。 ch=getchar(); SUB *insert(SUB *head) SUB *ptr,*ptr2,*subj; int size=sizeof(SUB); char ch='a',ch1; while(ch!=' ') subj=(SUB *)malloc(size); ptr=subj; printf("输入要插入的课程信息:n"); scan
13、f("%d%s%s%d%d%d%d%d",&subj->num,subj->name,subj->kind,&subj->stime,&subj->ttime,&subj->etime,&subj->score,&subj->term); if(head=NULL) head=ptr; head->next=NULL; else for(ptr2=head;ptr2;ptr2=ptr2->next) if(ptr2->next=NULL) ptr2->ne
14、xt=subj; subj->next=NULL; break; printf("继续插入请按回车,结束请按空格:n"); ch1=getchar(); /将回车键赋给CH1,否则subj->term输完后输入的回车键会赋给CH,因此用CH1填补。 ch=getchar(); return head; SUB *del(SUB *head) SUB *p1,*p2; char ch='a',ch1; int num; while(ch!=' ') printf("输入想要删除的课程编号:n"); scanf(&
15、quot;%d",&num); if(head->num=num) p2=head; head=head->next; free(p2); if(head=NULL) return NULL; p1=head; p2=head->next; while(p2) if(p2->num=num) p1->next=p2->next; free(p2); else p1=p2; p2=p1->next; printf("继续删除请按回车,结束请按空格:n"); ch1=getchar(); /将回车键赋给CH1,否则nu
16、m输完后再输入的回车键会赋给CH,因此用CH1填补。 ch=getchar(); return head; void choose(SUB *head) SUB *p,*q; int a5; int num,total=0,i=0,j; printf("输入要选修的课程的编号,编号之间以空格分开,输完后以0结束n");scanf("%d",&num); while(num!=0) for(p=head;p;p=p->next) if(p->num=num) total=total+p->score; ai=num; i+; sc
17、anf("%d",&num); if(total<60) printf("选修总学分未达到60,选修失败!n"); else printf("选修成功!n"); printf("您选修的课程为:n"); for(j=0;j<i;j+) for(q=head;q;q=q->next) if(q->num=aj) printf("%s ",q->name); printf("n");printf("*n");printf("*n");printf("*n");printf("*n"); void main() SUB *head=create_form(); sav
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 字音(解析版)-2026年中考语文复习试题(天津专用)
- 新高考化学实验新考法专项复习:操作顺序排列(解析版)
- PremiereProCS6视频编辑案例教程课件 第 8 章 输出文件
- 用电客户受理员理论知识考试题(附答案)
- 儿童网络安全意识培养的长期效果评估考核试卷
- 印刷化学品绿色生产与土壤污染预防技术探讨考核试卷
- 双控体系评估指标体系考核试卷
- 清洗设备操作人员培训考核试卷
- 最短线路问题-六年级数学思维拓展专项培优卷
- 临床思维训练与医学生临床实践适应性的关系考核试卷
- 康复家长培训
- 教育数字化背景下虚拟仿真实训教学资源的建设与开放共享模式探索
- 地铁工程质量培训
- 断舍离课件教学课件
- 云南博物馆招聘笔试真题2024
- QGDW11937-2018快速动态响应同步调相机组运维规范
- 供水公司库房管理制度
- 方便面面试题及答案
- T/CMES 37003-2022景区玻璃类观景设施安全规范
- 2025年婴幼儿配方食品营养配方中的营养素含量与食品添加剂的安全评估报告
- 2026高考地理《图表题策略》 复习课件
评论
0/150
提交评论