C语言程序设计报告—学生选修课程系统
c语言课程设计学生选课系统

c语言课程设计 学生选课系统一、课程目标知识目标:1. 学生能理解C语言在开发学生选课系统中的应用,掌握基本的数据结构(如结构体、数组、链表)和文件操作相关知识。
2. 学生能运用C语言实现学生选课系统的基本功能,如学生信息管理、课程信息管理、选课操作等。
3. 学生能理解并掌握C语言中的模块化编程思想,将学生选课系统分解为多个函数,提高代码的可读性和可维护性。
技能目标:1. 学生能运用C语言编写、调试和运行学生选课系统,具备一定的编程实践能力。
2. 学生能通过团队协作,共同完成一个完整的学生选课系统项目,提高沟通与协作能力。
3. 学生能运用所学知识,对现有学生选课系统进行优化和改进,提高系统性能。
情感态度价值观目标:1. 学生通过本课程的学习,培养对计算机编程的兴趣和热情,树立学习C语言的自信心。
2. 学生在团队协作中,学会尊重他人意见,培养合作精神和团队意识。
3. 学生能够认识到编程在解决实际问题中的价值,提高将所学知识应用于实际生活的意识。
课程性质:本课程为C语言编程实践课程,旨在让学生通过动手实践,掌握C 语言编程技能,并运用所学知识解决实际问题。
学生特点:学生已具备一定的C语言基础,具备基本编程能力,但缺乏实际项目经验。
教学要求:注重理论与实践相结合,强调编程实践,培养学生解决实际问题的能力。
通过团队协作,提高学生的沟通与协作能力。
在教学过程中,关注学生的个体差异,因材施教,使每位学生都能在原有基础上得到提高。
二、教学内容1. 数据结构基础:回顾结构体、数组、链表等基本数据结构,讲解其在学生选课系统中的应用。
相关教材章节:第3章 数据类型与表达式,第4章 控制结构,第5章 函数,第6章 数组与字符串,第7章 指针与结构体。
2. 文件操作:介绍文件读写、文件管理等基本操作,为学生选课系统提供数据持久化支持。
相关教材章节:第10章 文件操作。
3. 模块化编程:讲解模块化编程思想,引导学生将学生选课系统分解为多个函数,提高代码的可读性和可维护性。
C语言课程设计学生选修课系统设计

汇报人:
目录
添加目录标题
系统概述
系统需求分析
系统设计
系统实现
系统部署与维护
添加章节标题
系统概述
提高学生编程能力
方便教师管理课程设计项目
添加标题
添加标题
提供课程设计实践平台
添加标题
添加标题
促进学生之间的交流与合作
学生选课:查看课程信息,选择感兴趣的课程 教师管理:发布课程信息,管理学生选课情况 教务管理:查看学生选课情况,统计课程报名人数 系统维护:更新课程信息,维护系统正常运行
系统评估与总结
功能完整性:系统是否具备所有必需的 功能
性能稳定性:系统在运行过程中是否稳 定,是否会出现崩溃或错误
用户体验:系统的界面设计、操作流程 是否符合用户习惯,是否易于使用
安全性:系统是否具备足够的安全措施, 如数据加密、用户认证等
可扩展性:系统是否具备良好的可扩展 性,能够适应未来的需求变化
硬件要求:服务器、网络设备、存储设备等 软件要求:操作系统、数据库管理系统、Web服务器等
部署步骤:安装操作系统、安装数据库管理系统、安装Web服务器、部署应用程序等
维护方案:定期备份数据、定期检查系统运行状况、定期更新软件等
定期备份数据:确保数据安全, 防止数据丢失
定期更新软件:确保系统安全, 防止病毒和恶意软件攻击
管理员模块:用户管理、课程管理、选 课管理、成绩管理等操作
系统实现
数据库类型:MySQL
数据库操作:增删改查、事务处理、 备份恢复
添加标题
添加标题
添加标题
添加标题
数据库设计:表结构设计、字段设 计、索引设计
数据库优化:查询优化、索引优化、 存储优化
C语言程序设计报告—学生选修课程系统

p->classperiod=classperiod;//指向结构体变量中的成员
p->experiperiod=experiperiod;
p->creditHour=creditHour;
p->term=term;
if(head==NULL)
head=p;//,如果链表为空,head指向该结点
}SUB;
SUB *head=NULL;//head,头指针
SUB *create_form() //创建链表
{
SUB *head,*tail,*p;//定义结构体指针变量
int courseCode,totalperiod,classperiod;
int experiperiod,term;
float creditHour;
char courseName[20],courseType[10];
int size=sizeof(SUB);
head=tail=NULL;//将空地址赋给头指针,链表中无结点
printf("输入选修课程信息:\n");
scanf("%d%s%s%d%d%d%f%d",&courseCode,courseName,courseType,&totalperiod,&classperiod,&experiperiod,&creditHour,&term);
char courseType[10]; //课程性质
int totalperiod; //总学时
int classperiod; //授课学时
C语言程序设计报告—学生选修课程系统

中南民族大学C综合设计报告学院:电子信息工程学院专业:年级:题目:姓名:指导老师:2019年6月3日星期一C语言程序设计报告一、C语言课程设计的目的:高级语言课程设计是学习完《高级语言程序设计》课程后进行的一次全面的综合性上机实验。
其目的在于为同学提供了一个既动手又动脑,独立实践的机会,将课本上的理论知识和实际有机的结合起来,锻炼同学的分析解决实际问题的能力。
提高学生适应实际,实践编程的能力。
二、题目学生选修课程系统设计假定有n门课程,每门课程有课程编号、课程名称、课程性质、总学时、授课学时、实验或商机学时、血粉、开课学期等信息,学生可按要求(如总学分不得少于60)自由选课。
1、要求:试设计一个选修课程系统,使之能提供以下功能:(1)系统以菜单方式工作。
(2)课程信息和学生选课信息输入功能(课程信息用文件保存)——输入。
(3)课程信息浏览功能——输出。
(4)查询功能(至少一种查询方式)——算法。
(5)按学分查询。
(6)某门课程学生选修情况(可选项)。
2、分析:由于题目要求将学生的选课信息用结构体形式输入,并写入文件中,所以应提供文件的输入输出等操作:在过程中需有浏览、插入、修改、查找、删除学生选课信息等操作,顾应分别建立个功能模块;另外还应提供键盘式选择菜单实现程序运行。
3、总体设计:根据题目要求,可以将系统分为六个模块:1)系统以菜单方式工作模块;2)课程信息与学生选课信息录入功能模块;3)课程信息浏览功能模块;4)查询模块;5)按学分查询模块;6)某些课程学生选修情况模块。
4详细设计:#include <stdio.h>#include <stdlib.h> 主流程图:#include <string.h> Arraytypedef 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 *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("%d %s %s %d %d %d %d %d",&num,&name,&kind,&stime,&ttime,&eti me,&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;elsetail->next=p;tail=p;scanf("%d %s %s %d %d %d %d%d",&num,&name,&kind,&stime,&ttime,&eti me,&score,&term);}tail->next=NULL;return head;}void savefile(SUB *head) Array {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%7d\n",p->num,p->name,p->kind,p ->stime,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%7d\n",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)fprintf(fp,"%5d%12s%9s%9d%9d%11d%11d%7d\n",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");for(ptr=head;ptr;ptr=ptr->next)printf("%5d%12s%9s%9d%9d%11d%11d%7d\n",ptr->num,ptr->name,ptr->kind,ptr->stime,ptr->ttime,ptr->etime,ptr->score,ptr->term);}{int a,num;int t=1;char type[10];char ch='a',ch1;SUB *ptr;while(ch!=' '){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){printf("%5d%12s%9s%9d%9d%11d%11d%7d\n",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("课程编号课程名称课程性质总学时授课学时实践或上机学时学分开课学期\n");for(ptr=head;ptr;ptr=ptr->next)if(ptr->score==num){printf("%5d%12s%9s%9d%9d%11d%11d%7d\n",ptr->num,ptr->name,ptr->kind, ptr->stime,ptr->ttime,ptr->etime,ptr->score,ptr->term);t=0;}if(t) printf("未找到!\n");t=1;}printf("继续查找请按回车键,结束请按空格键:\n");ch1=getchar(); //将回车键赋给CH1,否则CASE里面最后输入的回车键会赋给CH,因此用CH1填补。
C语言程序设计报告学生选修课系统

C语言程序设计学校:学院:班级序号:学号::姓名指导老师:C语言程序设计报告一、C语言课程设计的目的:高级语言课程设计是学习完《高级语言程序设计》课程后进行的一次全面的综合性上机实验。
其目的在于为同学提供了一个既动手又动脑,独立实践的机会,将课本上的理论知识和实际有机的结合起来,锻炼同学的分析解决实际问题的能力。
提高学生适应实际,实践编程的能力。
二、题目学生选修课程系统设计假定有n门课程,每门课程有课程编号、课程名称、课程性质、总学时、授课学时、实验或商机学时、血粉、开课学期等信息,学生可按要求(如总学分不得少于60)自由选课。
1、要求:试设计一个选修课程系统,使之能提供以下功能:(1)系统以菜单方式工作。
(2)课程信息和学生选课信息输入功能(课程信息用文件保存)——输入。
(3)课程信息浏览功能——输出。
(4)查询功能(至少一种查询方式)——算法。
(5)按学分查询。
(6)某门课程学生选修情况(可选项)。
2、分析:由于题目要求将学生的选课信息用结构体形式输入,并写入文件中,所以应提供文件的输入输出等操作:在过程中需有浏览、插入、修改、查找、删除学生选课信息等操作,顾应分别建立个功能模块;另外还应提供键盘式选择菜单实现程序运行。
3、总体设计:根据题目要求,可以将系统分为六个模块:1)系统以菜单方式工作模块;2)课程信息与学生选课信息录入功能模块;3)课程信息浏览功能模块;4)查询模块;5)按学分查询模块;6)某些课程学生选修情况模块。
块设计:细4详#include <stdio.h>:程主流图#include <stdlib.h>#include <string.h>开始typedef struct subjects{int num; 显示一系列功能选择char name[20];char kind[10];int stime;N判断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;char name[20],kind[10];int size=sizeof(SUB);head=tail=NULL;牰湩晴尨输入选修课程信息:\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->kind,kind);p->stime=stime;p->ttime=ttime;p->etime=etime;p->score=score;p->term=term;if(head==NULL)head=p;elsetail->next=p;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 savefile(SUB *head){ 开始SUB *p;FILE *fp;fp=fopen(subjects.txt,w); 输出写入文件并储存输入结束灦楲瑮?灦尬课程编号课程名称课程性质总学时授课学时实验或上机学时学分开课学期\n);for(p=head;p;p=p->next)fprintf(fp,]_x0012_s%9s??dd}\n,p->num,p->name,p->kind,p->stime,p->ttime,p->etime,p->score,p->term);fclose(fp);}void savefileadd(SUB *head){SUB *p;FILE *fp;fp=fopen(subjectsadd.txt,w);灦楲瑮?灦尬课程编号课程名称课程性质总学时授课学时实验或上机学时学分开课学期\n);for(p=head;p;p=p->next)fprintf(fp,]_x0012_s%9s??dd}\n,p->num,p->name,p->kind,p->stime,p->ttime,p->etime,p->score,p->te rm);fclose(fp);}void savefiledel(SUB *head){SUB *p;FILE *fp;fp=fopen(subjectsdel.txt,w);灦楲瑮?灦尬课程编号课程名称课程性质总学时授课学时实验或上机学时学分开课学期\n);for(p=head;p;p=p->next)fprintf(fp,]_x0012_s%9s??dd}\n,p->num,p->name,p->kind,p->stime,p->ttime,p->etime,p->score,p->te rm);fclose(fp);}void prin(SUB *head){SUB *ptr;if(head==NULL){牰湩晴尨没有此门课程记录!\n);return;}牰湩晴尨课程编号课程名称课程性质总学时授课学时实践或上机学时学分开课学期\n);for(ptr=head;ptr;ptr=ptr->next)printf(]_x0012_s%9s??dd}\n,ptr->num,ptr->name,ptr->kind,ptr->stime,ptr->ttime,ptr->etime,ptr->scor e,ptr->term);}void search(SUB *head) 开始{int a,num;打开文件查看学生选课信息int t=1;char type[10];char ch='a',ch1;21SUB *ptr;判断查询方法查分学按质性按课程输入结束while(ch!=' '){2:\n); 输入分查找请1程要按课性质查找请输入,若要按学若牰湩晴尨scanf(%d,&a); switch(a){:\n); 的性质入慣敳ㄠ瀺楲瑮?请输要查找的课程scanf(%s,type);或实践学程称名课性质总学时授课时程号程牰湩晴尨课编课\n); 学分学期开课时机上学for(ptr=head;ptr;ptr=ptr->next)if(strcmp(type,ptr->kind)==0){printf(]_x0012_s%9s??dd}\n,ptr->num,ptr->name,ptr->kind,ptr->stime,ptr->ttime,ptr->etime,ptr->scor e,ptr->term);t=0;}晩琨?牰湩晴尨未找到!\n);t=1;break;慣敳㈠瀺楲瑮?输入要查找的课程的学分\n);scanf(%d,&num);牰湩晴尨课程编号课程名称课程性质总学时授课学时实践或上机学时学分开课学期\n);for(ptr=head;ptr;ptr=ptr->next)if(ptr->score==num){printf(]_x0012_s%9s??dd}\n,ptr->num,ptr->name,ptr->kind,ptr->stime,ptr->ttime,ptr->etime,ptr->scor e,ptr->term);t=0;}晩琨?牰湩晴尨未找到!\n);t=1;}牰湩晴尨继续查找请按回车键,结束请按空格键:\n);ch1=getchar(); //将回车键赋给CH1,否则CASE里面最后输入的回车键会赋给CH,因此用CH1填补。
C语言课程设计实践报告——《学生选课管理系统》[内附程序源代码]
![C语言课程设计实践报告——《学生选课管理系统》[内附程序源代码]](https://img.taocdn.com/s3/m/e8a7a60916fc700abb68fcac.png)
C语言大型作业实践报告计算机1001制作者:李菁华张兆丰秦恒加2011年6月题目:选修课程管理系统要求:假定有N门选修课,每门课有课程编号、名称、课程性质、总学时、授课学时、实验或上机学时、学分、开课学期等信息。
学生可按要求(如总学分不能少于20学分)选课。
▪课程信息维护,如录入、修改、删除等,课程信息用文件保存。
▪课程信息浏览—输出。
▪学生选课功能。
▪查询功能包括:按学分、课程性质、学生等查询。
▪统计功能。
统计各门课程的选修人数。
▪本系统要有通用性、界面美观、操作方便。
要考虑系统安全。
具体算法流程设计思路(流程图):程序源代码:#include<stdio.h>#include<time.h>#include<string.h>#include<conio.h>main(){intx,xi,choice2,choice3,choice4,choice8,q=0,filein=0,limit=0,i,num,tonum,tcnum,ecnum ,score,term,student,A,io=0,screen=0;/*-----变量定义区-----,x为现有选修课数量,目前不能超过10,后续与主程序合并时移动到定义区,xi为选修课信息录入循环变量*/char choice1,choice5,choice6,choice7,name[10],kind[10];int carenum[10]={0,0,0,0,0,0,0,0,0,0}; /*用于统计每门课程选修人数*/int o,change=0,delatenum,e,u,stui=0,stuc=0;struct elective /*选修课程信息结构体*/{int electivenum; /*选修课编号*/char electivename[10]; /*选修课课名*/char electivekind[10]; /*选修课性质,暂定考试考查之分*/int totalclassnum; /*总课时*/int techclassnum; /*授课课时*/int expclassnum; /*实验课时*/int credits; /*学分*/int classterm; /*开课学期*/int students; /*此门课选修人数*/};struct muticlass /*学生选择的课程信息结构体*/{int stuchoice;int stuclassnum;char stuclassname;};struct student /*学生信息结构体*/{char stuname[10];long stunum;int stucredits;struct muticlass mutichoice[20]; /*暂定每名学生最多选20门课*/ /*本结构体为嵌套结构体,完善功能时请注意嵌套结构*/};struct student studentcare[100]; /*暂定最多可以有100名学生选课*/struct elective electivedata[10]; /*最多10门选修课*/FILE *electivefp; /*选修课程信息文件指针*/FILE *stufp; /*学生信息文件指针*/FILE *outfp; /*课程信息输出文件指针*/FILE *find;long now,midkey; /*now为密码算法中间变量,midkey为密码算法最终结果*/int chancenum=0,m; /*chancenum为输入密码错我次数计数变量,m为主目录选择判断变量*/unsigned long password,password2;struct tm *timenow; /*timenow为标准系统时间提取指针*/textcolor(WHITE);system("cls");gotoxy(20,12);cprintf("Welcome to the Elective management system"); /*一级主菜单*/gotoxy(1,24);system("pause");t2:system("cls");gotoxy(24,11);cprintf("1.Students elective course system");gotoxy(24,12);cprintf("2.Elective information output");gotoxy(24,13);cprintf("3.Elective course information searching");gotoxy(24,14);cprintf("4.I'm the administrator!");gotoxy(24,15);cprintf("5.Exit the system");gotoxy(24,16);scanf("%d",&choice8);switch(choice8){case 1: limit=0;goto students1;case 2: goto x11;case 3: goto x12;case 4: goto x7;case 5: goto x3;default: system("cls");gotoxy(20,12);cprintf("wrongchoice");gotoxy(1,24);system("pause");goto t2;}x7:textcolor(YELLOW); /*-----密码判断模块-----*/time(&now);midkey=now;midkey=midkey/100;password=midkey;return2:system("cls");gotoxy(22,15);cprintf("Enter 1 to refresh the password.");gotoxy(25,12);cprintf("Please enter your password\n");gotoxy(25,13);scanf("%ld",&password2); /*password2为用户输入的密码变量*/ if(chancenum<4) /*用户输入密码错误次数判断*/{if(password2==password){limit=1;goto x4;}else{if(password2==1){goto x7;}else{system("cls");gotoxy(22,12);textcolor(RED);cprintf("password error");gotoxy(18,13);cprintf("please enter the right password");gotoxy(20,14);cprintf("You have only %d chances",3-chancenum);gotoxy(1,24);system("pause");if(chancenum==3) /*连续4次输入错误密码判断*/{goto x6;}chancenum=chancenum+1;goto return2;}}}x6:system("cls");gotoxy(20,12);cprintf(" Sorry,you have null chance.");gotoxy(1,24);goto x5; /*-----密码判断模块结束-----*/x4:switch(limit){case 0: textcolor(YELLOW);goto students1;case 1: textcolor(GREEN);goto t3;default: textcolor(RED);system("cls");gotoxy(20,12);cprintf("None Limited");gotoxy(1,24);system("pause");textcolor(WHITE);goto t2;}t3:textcolor(GREEN); /*-----主程序开始-----*/system("cls");gotoxy(20,12);cprintf("Welcome to the Elective management system"); /*一级主菜单*/gotoxy(1,24);system("pause");return1:system("cls");gotoxy(24,3);cprintf("Elective management system"); /*选修课管理系统*/gotoxy(24,11);cprintf("1.Students elective course system."); /*学生选课系统*/gotoxy(24,12);cprintf("2.Elective course maintenance system."); /*课程信息维护系统*/gotoxy(24,13);cprintf("3.Exit the system."); /*退出系统*/gotoxy(24,14);scanf("%d",&o);switch(o){case 1: goto students1;case 2: goto electivemans1;case 3: goto x3;default: system("cls");gotoxy(12,12);cprintf("error choice,please make your choice again\n");gotoxy(1,24);system("pause");goto return1;}electivemans1:system("cls");change=0;gotoxy(24,3);cprintf("Elective management system"); /*二级主菜单*/gotoxy(24,11);cprintf("1.New elective database"); /*新建选修课程信息*/gotoxy(24,12);cprintf("2.Maintain elective database"); /*修改选修课程信息*/gotoxy(24,13);cprintf("3.Show the number of statistical electives"); /*统计每门课程选修人数*/gotoxy(24,14);cprintf("4.Elective information output"); /*课程信息输出*/gotoxy(24,15);cprintf("5.Return to the main menu"); /*返回主菜单*/gotoxy(24,16);scanf("%d",&m);switch(m) /*主目录跳转判断*/{case 1: goto x1;case 2: goto x2;case 3: goto x8;case 4: goto x11;case 5: goto return1;default: system("cls");gotoxy(12,12);cprintf("error choice,please make your choice again\n");gotoxy(1,24);system("pause");goto electivemans1;}x3:system("cls");gotoxy(25,12);cprintf("Thanks for using thissystem");gotoxy(1,24);goto x5;x1:electivefp=fopen("elective.dat","w+"); /*-----选修课程信息新建模块-----*/ if((electivefp=fopen("elective.dat","w+"))==NULL){gotoxy(12,12);cprintf("connot open this file");gotoxy(11,13);cprintf("Please debug this program");gotoxy(12,17);system("pause");goto z1;}system("cls");gotoxy(12,12);cprintf("Please according to clew input elective course information");gotoxy(1,24);system("pause");a1:system("cls");gotoxy(12,12);cprintf("Please input the elective quantity,Up to 10."); /*输入此次录入选修课程门数*/gotoxy(14,13);scanf("%d",&x); /*输入选修课总课程数*/if(x>10) /*总课程数小于10判断*/{system("cls");gotoxy(12,12);cprintf("Up to 10");gotoxy(1,24);system("pause");goto a1;}for(xi=0;xi<x;xi++) /*课程信息录入*/{r1:system("cls"); /*课程信息开始录入*/gotoxy(12,11);cprintf("Please enter the No.%d elective course numbers",xi+1);gotoxy(12,12);scanf("%d",&electivedata[xi].electivenum);if(q==1){goto z4;}r2:system("cls");gotoxy(12,11);cprintf("Please input the name of the No.%d elective course class",xi+1);gotoxy(12,12);scanf("%s",&electivedata[xi].electivename);if(q==1){goto z4;}r3:system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective properties,\"exam\" or \"examines\"",xi+1);gotoxy(12,12);scanf("%s",&electivedata[xi].electivekind);if(q==1){goto z4;}r4:system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective total class number",xi+1);gotoxy(12,12);scanf("%d",&electivedata[xi].totalclassnum);if(q==1){goto z4;}r5:system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective lecture class number",xi+1);gotoxy(12,12);scanf("%d",&electivedata[xi].techclassnum);if(q==1){goto z4;}r6:system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective the experiment class number",xi+1);gotoxy(12,12);scanf("%d",&electivedata[xi].expclassnum);if(q==1){goto z4;}r7:system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective credits",xi+1);gotoxy(12,12);scanf("%d",&electivedata[xi].credits);if(q==1){goto z4;}r8:system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective course semesters",xi+1);gotoxy(12,12);scanf("%d",&electivedata[xi].classterm);if(q==1){goto z4;}if(xi<(x-1)){system("cls");gotoxy(12,12);cprintf("This elective information recorded success, please enter the next");gotoxy(1,24);system("pause");}} /*课程信息录入结束*/z4:system("cls"); /*课程信息输入正确性判断*/gotoxy(12,12);cprintf("If information recorded correctly?");gotoxy(14,13);cprintf("Enter \"y\" for Yes,\"n\" for No");gotoxy(14,14);scanf("%c",&choice1);switch(choice1){case 121: goto z2;case 110: goto z3;default: system("cls");gotoxy(12,12);cprintf("Wrong choicePlease make it again.");gotoxy(1,24);system("pause");goto z4;}z3:{ /*错误信息定位*/system("cls");gotoxy(8,5);cprintf("What message entry errors?");gotoxy(12,6);cprintf("1.elective course numbers");gotoxy(12,7);cprintf(" of elective course class");gotoxy(12,8);cprintf("3.elective properties");gotoxy(12,9);cprintf("4.elective total class number");gotoxy(12,10);cprintf("5.elective lecture class number");gotoxy(12,11);cprintf("6.elective experiment class number");gotoxy(12,12);cprintf("7.elective credits");gotoxy(12,13);cprintf("8.elective course semesters");gotoxy(12,14);cprintf("9.Add a elective course lesson.");gotoxy(12,15);cprintf("10.Delate a elective course lesson.");gotoxy(12,16);scanf("%d",&choice2); /*错误项目定位*/system("cls");if(choice2==9){goto r9;}elseif(choice2==10){goto r10;}else{goto z6;}z6:system("cls");gotoxy(12,12);cprintf("Which group of curriculum information need to modify?"); gotoxy(12,13);scanf("%d",&choice3); /*错误组别定位*/if(choice3<x+1&&choice3>0){goto z7;}else{system("cls");gotoxy(12,12);cprintf("Wrong group,please enter again");gotoxy(1,24);system("pause");goto z6;}z7:xi=choice3-1;switch(choice2) /*错误信息修改*/{case 1: q=1;goto r1;case 2: q=1;goto r2;case 3: q=1;goto r3;case 4: q=1;goto r4;case 5: q=1;goto r5;case 6: q=1;goto r6;case 7: q=1;goto r7;case 8: q=1;goto r8;case 9: q=1;goto r9;case 10: q=1;goto r10;default: system("cls");gotoxy(12,12);cprintf("Wrong choice.Please make it again.");gotoxy(1,24);system("pause");goto z3;}}z2:if(change==0){goto write1;}else{remove("elective.dat");electivefp=fopen("elective.dat","w+");goto write1;}write1:fprintf(electivefp,"%d \n",x);for(xi=0;xi<x;xi++) /*将完善的课程信息以文件的形式保存在磁盘上*/{electivedata[xi].students=0;fprintf(electivefp,"%d %s %s %d %d %d %d %d %d\n",electivedata[xi].electivenu m,electivedata[xi].electivename,electivedata[xi].electivekind,electivedata[xi].totalcla ssnum,electivedata[xi].techclassnum,electivedata[xi].expclassnum,electivedata[xi].cr edits,electivedata[xi].classterm,electivedata[xi].students);}filein=1;z1:{system("cls");gotoxy(12,12);cprintf("Elective course information input success!");gotoxy(1,24);system("pause");}goto return1; /*返回主菜单*/x2:change=1;if(filein==1){goto z3;}electivefp=fopen("elective.dat","r+");fscanf(electivefp,"%d \n",&x);for(xi=0;xi<x;xi++){fscanf(electivefp,"%d %s %s %d %d %d %d %d %d\n",&electivedata[xi].electiven um,&electivedata[xi].electivename,&electivedata[xi].electivekind,&electivedata[xi].t otalclassnum,&electivedata[xi].techclassnum,&electivedata[xi].expclassnum,&electiv edata[xi].credits,&electivedata[xi].classterm,&electivedata[xi].students);}goto z3;r9:x=x+1;system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective course numbers",x);gotoxy(12,12);scanf("%d",&electivedata[x-1].electivenum);system("cls");gotoxy(12,11);cprintf("Please input the name of the No.%d elective course class",x);gotoxy(12,12);scanf("%s",&electivedata[x-1].electivename);system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective properties,\"exam\" or \"examines\"",x);gotoxy(12,12);scanf("%s",&electivedata[x-1].electivekind);system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective total class number",x);gotoxy(12,12);scanf("%d",&electivedata[x-1].totalclassnum);system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective lecture class number",x);gotoxy(12,12);scanf("%d",&electivedata[x-1].techclassnum);system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective the experiment class number",x); gotoxy(12,12);scanf("%d",&electivedata[x-1].expclassnum);system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective credits",x);gotoxy(12,12);scanf("%d",&electivedata[x-1].credits);system("cls");gotoxy(12,11);cprintf("Please enter the No.%d elective course semesters",x);gotoxy(12,12);scanf("%d",&electivedata[x-1].classterm);goto z4;r10:system("cls");gotoxy(12,12);cprintf("Which group of elective do you want to delate?");gotoxy(12,13);scanf("%d",&delatenum);if(delatenum>0||delatenum<x){for(e=0;e<x-delatenum;e++){electivedata[delatenum+e-1]=electivedata[delatenum+e];}x=x-1;remove("elective.dat");electivefp=fopen("elective.dat","w+");}else{system("cls");gotoxy(12,12);cprintf("we do not have that group of elective information");gotoxy(1,24);system("pause");goto r10;}goto z4;students1:{electivefp=fopen("elective.dat","r+");fscanf(electivefp,"%d \n",&x);for(xi=0;xi<x;xi++){fscanf(electivefp,"%d %s %s %d %d %d %d %d %d\n",&electivedata[xi].electivenum, &electivedata[xi].electivename,&electivedata[xi].electivekind,&electivedata[xi].total classnum,&electivedata[xi].techclassnum,&electivedata[xi].expclassnum,&electiveda ta[xi].credits,&electivedata[xi].classterm,&electivedata[xi].students);}stufp=fopen("stu.dat","r+");return4:system("cls");gotoxy(12,12);cprintf("Please enter your name");gotoxy(12,13);scanf("%s",&studentcare[stui].stuname);system("cls");gotoxy(12,12);cprintf("Please enter your student ID");gotoxy(12,13);scanf("%ld",&studentcare[stui].stunum);care2:system("cls");gotoxy(3,2);cprintf("Existing elective");for(u=0;u<x;u++){gotoxy(5,u+3);cprintf("%d.num:%dname:%s\n",u+1,electivedata[u].electivenum,electivedata[u].electivename);}gotoxy(5,x+4);cprintf("Which are you interested?");gotoxy(5,x+5);scanf("%d",&choice4);return3:system("cls");gotoxy(3,2);cprintf("Elective information");gotoxy(4,4);cprintf("Num:%d",electivedata[choice4-1].electivenum);gotoxy(4,5);cprintf("Name:%s",electivedata[choice4-1].electivename);gotoxy(4,6);cprintf("Kind:%s",electivedata[choice4-1].electivekind);gotoxy(4,7);cprintf("Total class:%d",electivedata[choice4-1].totalclassnum);gotoxy(4,8);cprintf("Tech class:%d",electivedata[choice4-1].techclassnum);gotoxy(4,9);cprintf("Exp class:%d",electivedata[choice4-1].expclassnum);gotoxy(4,10);cprintf("Credits:%d",electivedata[choice4-1].credits);gotoxy(4,11);cprintf("Class term:%d",electivedata[choice4-1].classterm);gotoxy(4,14);cprintf("Sure to choose this course? enter \"y\" for yes,\"n\" for no");gotoxy(4,15);scanf("%c",&choice5);switch(choice5){case 121: goto care1;case 110: goto care2;default: system("cls");gotoxy(12,12);cprintf("wrong choice");goto return3;}care1:if(stuc>0){for(xi=0;xi<stuc+1;xi++){if(choice4==studentcare[stui].mutichoice[xi].stuclassnum){system("cls");gotoxy(12,12);cprintf("Connot repeat courses");gotoxy(1,24);system("pause");goto care2;}}}carenum[choice4-1]++;electivedata[choice4-1].students=carenum[choice4-1];studentcare[stui].mutichoice[stuc].stuchoice=choice4;studentcare[stui].stucredits=studentcare[stui].stucredits+electivedata[choice4-1 ].credits;studentcare[stui].mutichoice[stuc].stuclassnum=electivedata[choice4-1].elective num;studentcare[stui].mutichoice[stuc].stuclassname=electivedata[choice4-1].electiv ename;x10:system("cls");gotoxy(12,12);cprintf("Course whether end? enter \"y\" for yes,\"n\" for no");gotoxy(12,13);scanf("%c",&choice6);switch(choice6){case 121: goto x9;case 110: stuc++;goto care2;default: system("cls");gotoxy(12,12);cprintf("wrongchoice");gotoxy(1,24);system("pause");goto x10;}x9:if(studentcare[stui].stucredits<20){system("cls");gotoxy(12,12);cprintf("Attention!Total credits less than 20!");gotoxy(1,24);system("pause");goto x10;}else{remove("stu.dat");stufp=fopen("stu.dat","a+");fprintf(stufp,"%d \n",stui);system("cls");gotoxy(12,12);cprintf("Elective success!");gotoxy(1,24);system("pause");return6:system("cls");gotoxy(12,12);cprintf("If others need courses? enter \"y\" for yes,\"n\" for no");gotoxy(12,13);scanf("%c",&choice7);switch(choice7){case 121: stui++;goto return4;case 110: goto return5;default: system("cls");gotoxy(12,12);cprintf("wrong choice");gotoxy(1,24);system("pause");goto return6;}return5: for(u=0;u<stui+1;u++){fprintf(stufp,"%s %ld %d\n",studentcare[u].stuname,studentcare[u].stunum,studentcare[u].stucredits);for(xi=0;xi<stuc+1;xi++){fprintf(stufp,"%d %d %s\n",studentcare[u].mutichoice[xi].stuchoice,studentcare[u].mutichoice[xi].stuclassnu m,studentcare[u].mutichoice[xi].stuclassname);}}remove("elective.dat");electivefp=fopen("elective.dat","w+");fprintf(electivefp,"%d \n",x);for(xi=0;xi<x;xi++) /*将完善的课程信息以文件的形式保存在磁盘上*/{fprintf(electivefp,"%d %s %s %d %d %d %d %d %d\n",electivedata[xi].electivenum,el ectivedata[xi].electivename,electivedata[xi].electivekind,electivedata[xi].totalclassnu m,electivedata[xi].techclassnum,electivedata[xi].expclassnum,electivedata[xi].credits ,electivedata[xi].classterm,electivedata[xi].students);}switch(limit){case 1: goto return1;case 0: goto t2;default: goto t2;}}}x8:electivefp=fopen("elective.dat","r+");fscanf(electivefp,"%d \n",&x);for(xi=0;xi<x;xi++){fscanf(electivefp,"%d %s %s %d %d %d %d %d %d\n",&electivedata[xi].electivenum, &electivedata[xi].electivename,&electivedata[xi].electivekind,&electivedata[xi].total classnum,&electivedata[xi].techclassnum,&electivedata[xi].expclassnum,&electiveda ta[xi].credits,&electivedata[xi].classterm,&electivedata[xi].students);}system("cls");gotoxy(3,4);cprintf("Elective toll");for(u=0;u<x;u++){gotoxy(3,u+6);cprintf("%s : %d",electivedata[u].electivename,electivedata[u].students);}gotoxy(1,18);system("pause");goto electivemans1;x11:system("cls"); /*-----查找模块-----*/electivefp=fopen("elective.dat","r+");fscanf(electivefp,"%d \n",&x);for(xi=0;xi<x;xi++){fscanf(electivefp,"%d %s %s %d %d %d %d %d %d\n",&electivedata[xi].electivenum, &electivedata[xi].electivename,&electivedata[xi].electivekind,&electivedata[xi].total classnum,&electivedata[xi].techclassnum,&electivedata[xi].expclassnum,&electiveda ta[xi].credits,&electivedata[xi].classterm,&electivedata[xi].students);}outfp=fopen("electiveinformation.doc","w+");fprintf(outfp,"选修课程信息\n\n\n\n");for(xi=0;xi<x;xi++){fprintf(outfp,"课程编号:%d \n课程名:%s \n课程种类:%s \n总课时:%d \n教学课时:%d \n实验课时:%d \n学分:%d \n开课学期:%d \n已选人数:%d\n\n\n",electivedata[xi].electivenum,electivedata[xi].electivename,electivedat a[xi].electivekind,electivedata[xi].totalclassnum,electivedata[xi].techclassnum,electiv edata[xi].expclassnum,electivedata[xi].credits,electivedata[xi].classterm,electivedata [xi].students);}switch(limit){case 1: goto electivemans1;case 0: goto t2;default: goto t2;}x12:{find=fopen("elective.dat","r+");fscanf(find,"%d \n",&x);for(i=0;i<x;i++){fscanf(find,"%d %s %s %d %d %d %d %d %d\n",&electivedata[i].electivenum,&el ectivedata[i].electivename,&electivedata[i].electivekind,&electivedata[i].totalclassnu m,&electivedata[i].techclassnum,&electivedata[i].expclassnum,&electivedata[i].credi ts,&electivedata[i].classterm,&electivedata[i].students);}xx:io=0;system("cls");gotoxy(7,3);printf("a:search by electivenum;\n b:search by electivename;\nc:search by electivekind;\n d:search by totalclassnum;\n e:search by techclassnum;\n f:search by expclassnum;\n g:search by credits;\n h:search by classterm;\n i:search by students\n");gotoxy(7,12);cprintf("j:Return to the main menu");gotoxy(7,13);scanf("%c",&A);switch(A){case 97: goto a;case 98: goto b;case 99: goto c;case 100: goto d;case 101: goto e;case 102: goto f;case 103: goto g;case 104: goto h;case 105: goto i;case 106: goto t2;default: system("cls");gotoxy(24,12);cprintf("wrongchoice\n");system("pause");goto xx;}a:screen=0;{system("cls");gotoxy(24,12);cprintf("Please write down the electivenum\n");gotoxy(24,13);scanf("%d",&num);system("cls");for(i=0; i<x; i++){if(electivedata[i].electivenum==num){if(screen>0){system("pause");system("cls");}cprintf("Here is the information you want:\n");cprintf("num:%d\n",electivedata[i].electivenum);cprintf("name:%s\n",electivedata[i].electivename);cprintf("kind:%s\n",electivedata[i].electivekind);cprintf("class:%d\n",electivedata[i].totalclassnum);cprintf("techclass:%d\n",electivedata[i].techclassnum);cprintf("expclass:%d\n",electivedata[i].expclassnum);cprintf("credits:%d\n",electivedata[i].credits);cprintf("term:%d\n",electivedata[i].classterm);cprintf("students:%d\n",electivedata[i].students);io=1;screen=screen+1;} }if(io==0){system("cls");cprintf("wrong number");gotoxy(1,24);system("pause");goto xx;}system("pause");goto xx;}b:screen=0;{system("cls");gotoxy(24,12);cprintf("Please write down the electivename\n");gotoxy(24,13); scanf("%s",&name);system("cls");for(i=0; i<x; i++){if(strcmp(electivedata[i].electivename,name)==0){if(screen>0){system("pause");system("cls");}cprintf("Here is the information you want:\n");cprintf("num:%d\n",electivedata[i].electivenum);cprintf("name:%s\n",electivedata[i].electivename);cprintf("kind:%s\n",electivedata[i].electivekind);cprintf("class:%d\n",electivedata[i].totalclassnum);cprintf("techclass:%d\n",electivedata[i].techclassnum);cprintf("expclass:%d\n",electivedata[i].expclassnum);cprintf("credits:%d\n",electivedata[i].credits);cprintf("term:%d\n",electivedata[i].classterm);cprintf("students:%d\n",electivedata[i].students);io=1;screen=screen+1;}}if(io==0){system("cls");cprintf("wrong number");gotoxy(1,24);system("pause");goto xx;}system("pause");goto xx;}c:screen=0;{system("cls");gotoxy(24,12);cprintf("Please write down the electivenkind\n");gotoxy(24,13); scanf("%s",&kind);system("cls");for(i=0; i<x; i++){if(strcmp(electivedata[i].electivekind,kind)==0){if(screen>0){system("pause");system("cls");}cprintf("Here is the information you want:\n");cprintf("num:%d\n",electivedata[i].electivenum);cprintf("name:%s\n",electivedata[i].electivename);cprintf("kind:%s\n",electivedata[i].electivekind);cprintf("class:%d\n",electivedata[i].totalclassnum);cprintf("techclass:%d\n",electivedata[i].techclassnum);cprintf("expclass:%d\n",electivedata[i].expclassnum);cprintf("credits:%d\n",electivedata[i].credits);cprintf("term:%d\n",electivedata[i].classterm);cprintf("students:%d\n",electivedata[i].students);io=1; screen=screen+1;} }if(io==0){system("cls");cprintf("wrong number");gotoxy(1,24);system("pause");goto xx;}system("pause");goto xx;}d:screen=0;{system("cls");gotoxy(24,12);cprintf("Please write down the totalclassnum\n");gotoxy(24,13); scanf("%d",&tonum);system("cls");for(i=0; i<x; i++){if(electivedata[i].totalclassnum==tonum){if(screen>0){system("pause");system("cls");}cprintf("Here is the information you want:\n");cprintf("num:%d\n",electivedata[i].electivenum);cprintf("name:%s\n",electivedata[i].electivename);cprintf("kind:%s\n",electivedata[i].electivekind);cprintf("class:%d\n",electivedata[i].totalclassnum);cprintf("techclass:%d\n",electivedata[i].techclassnum);cprintf("expclass:%d\n",electivedata[i].expclassnum);cprintf("credits:%d\n",electivedata[i].credits);cprintf("term:%d\n",electivedata[i].classterm);cprintf("students:%d\n",electivedata[i].students);io=1;screen=screen+1;} }if(io==0){system("cls");cprintf("wrong number");gotoxy(1,24);system("pause");goto xx;}system("pause");goto xx;}e:screen=0;{system("cls");gotoxy(24,12);cprintf("Please write down the techclassnum\n");gotoxy(24,13); scanf("%d",&tcnum);system("cls");for(i=0; i<x; i++){if(electivedata[i].techclassnum==tcnum){if(screen>0){system("pause");system("cls");}cprintf("Here is the information you want:\n");cprintf("num:%d\n",electivedata[i].electivenum);。
c语言课程设计学生选课管理系统实验报告

课程设计报告课程设计题目:学生选课管理系统学号:09110712姓名:李唐松专业:软件工程班级: 091107指导老师:谢小林2009年1月5日星期二*实验题目:学分管理程序*实验时间与地点:2009年1月7日星期四软件楼508*实验目的:1综合运用所学的C语言知识进行编程。
2进一步了解掌握C的基本语法。
3开始逐步培养编程思维,完善编程思维漏洞。
4侧重对C中数组函数指针结构体和文件等相关内容的综合应用。
4进一步提升自己的编程能力,为以后学习开始奠基。
*实验要求:1学生选课信息的添加(学生选课信息包括学生学生学号、课程名称、学分)2学生选课信息的删除3学生选课信息的查询(查询每个学生的选课信息,每个学生选课的总学分,选具体某门课程(课程名输入)的学生名单)*实验思路:1.函数定义判断,调用函数实现函数功能。
2.首先自定义函数,做出主菜单。
3.运用do….while , switch 语句完成主函数。
4.主程序中调用函数,程序运行时实现菜单选择功能。
5.自定义函数主要if语句完成,注重函数的应用。
*流程图:A主干图B具体流程:*程序操作:#i n c l u d e<s t d i o.h>#i n c l u d e<s t r i n g.h>#i n d e f i n e s i z e10s t r u c t c o u r s e{l o n g n u m;c h a r c o u r s e1[20];i n t s c o r e1;c h a r c o u r s e2[20];i n t s c o r e2;c h a r c o u r s e3[20];i n t s c o r e3;c h a r c o u r s e4[20];i n t s c o r e4;}c o u r s e[s i z e];v o i d m e n u(){p r i n t f(“*************************\n”); p r i n t f(“学生选课管理系统\n”);p r i n t f(“************************\n”); p r i n t f(“0退出程序\n“);p r i n t f(“1学生选课信息的添加\n”);p r i n t f(“2学生选课信息的删除\n”);p r i n t f(“3学生选课信息的查询\n”);p r i n t f(“请输入0~3\n”);}v o i d s u r e(){i n t i;f o r(i=0;i<s i z e;i++)p r i n t f(“学号:\n”);s c a n f(“%l d”,c o u r s e[i].n u m);p r i n t f(“课程1:\n”);s c a n f(“%s”,c o u r s e[i].c o u r s e1);p r i n t f(“学分1:\n”);s c a n f(“%d”,c o u r s e[i].s c o r e1);p r i n t f(“课程2:\n”);s c a n f(“%s”,c o u r s e[i].c o u r s e2);p r i n t f(“学分2:\n”);s c a n f(“%d”,c o u r s e[i].s c o r e2);p r i n t f(“课程3:\n”);s c a n f(“%s”,c o u r s e[i].c o u r s e3);p r i n t f(“学分3:\n”);s c a n f(“%d”,c o u r s e[i].s c o r e3);p r i n t f(“课程4:\n”);s c a n f(“%s”,c o u r s e[i].c o u r s e1);p r i n t f(“学分4:\n”);s c a n f(“%d”,c o u r s e[i].s c o r e4);i f(s t r c m p(c o u r s e[i].c o u r s e1)==0)r e t u r n;i f(s t r c m p(c o u r s e[i].c o u r s e2)==0)r e t u r n;i f(s t r c m p(c o u r s e[i].c o u r s e3)==0)r e t u r n;i f(s t r c m p(c o u r s e[i].c o u r s e4)==0)r e t u r n;}v o i d d e l(){i n t i;l o n g n;p r i n t f(“请输入学号:\n”);s c a n f(“%l d”,&n);f o r(i=0;i<=s i z e;i++)i f(c o u r s e[i].n u m==n)c o u r s e[i].n u m=c o u r s e[i+1].n u ms t r c p y(c o u r s e[i].c o u r s e1,c o u r s e[i+1].c o u r s e1);c o u r s e[s i z e].c o u r s e1=”\o”c o u r s e[i].s c o r e1=c o u r s e[i+1].s c o r e2;c o u r s e[i].s c o r e2=c o u r s e[i+1].s c o r e3;c o u r s e[i].s c o r e3=c o u r s e[i+1].s c o r e4;}v o i d o p e n(){i n t i;l o n g n;i n t s c o r e;p r i n t f(“请输入学号:”);s c a n f(“%l d”,&n);f o r(i=0;i<s i z e;i++)i f(c o u r s e[i].n u m==n){p r i n t f(“学号:%l d”,c o u r s e[i].n u m);p r i n t f(“课程1:%s”,c o u r s e[i].c o u r s e1);p r i n t f(“学分1:%d”,c o u r s e[i].s c o r e1);p r i n t f(“课程2:%s”,c o u r s e[i].c o u r s e2);p r i n t f(“学分2:%d”,c o u r s e[i].s c o r e2);p r i n t f(“课程3:%s”,c o u r s e[i].c o u r s e3);p r i n t f(“学分3:%d”,c o u r s e[i].s c o r e3);p r i n t f(“课程4:%s”,c o u r s e[i].c o u r s e4);p r i n t f(“学分4:%d”,c o u r s e[i].s c o r e4);s c o r e=c o u r s e[i].s c o r e1+c o u r s e[i].s c o r e2+c o r s e[i].s c o r e3+c o u r s e[i].s c o r e4; p r i n t f(“总学分:%d”,s c o r e);}v o i d m a i n(){i n t n;s c a n f(“%d”,&n);d o{me n u();s w i t c h(n){c a s e1:s u r e();b r e a k;c a s e2:de l();b r e a k;c a s e3:o p e n();b r e a k;}}w h i l e(n!=0)}实验总结:1.运用该程序可以顺利完成学生选课的添加、删除以及查询。
C语言课程设计-学生选修课程系统设计

printf("Chiose your number(1-5):[ ]\b\b"); scanf("%d",&n); switch(n) { case 1:prin();break; case 2:search();break; case 3:insert();savefile();break; c case 5:return; default:; } } while(w==1); }
学生选修课系统设计
一、设计目的 当今时代是飞速发展的信息时代,在各行各业中离不开信息处理, 这正是计算机被广泛应用于信息系统的环境。计算机的最到好处的于利 用它能够进行信息管理,使用计算机进行信息控制,不仅提高了工作效 率,而且大大的提高了其安全性。 尤其对于复杂的信息管理,计算机能够充分发挥它的优越性。计算 机进行信息管理与信息管理系统的开发密切相关,系统的开发是系统管 理的前提。本系统就是为了管理好学生选课信息而设计的。 数据处理手工操作,工作量大,出错率高,出错后不易更改,造成 了时间上的浪费。 基于这个问题,我认为有必要建立一个学生选课系统,使学生选课 信息管理工作规范化、系统化、程序化,避免学生选课管理的随意性, 提高信息处理的速度和准确性,能够及时、准确、有效的查询和修改选 课情况。 二、题目说明 假定有n门课程,每门课程都有课程编号,课程名称,课程性质,总 学时,授课学时,实验或上机学时,学分,开课学期等信息,学生可按 要求(如总学分不得少于60)自由选课。试设计一选修课程系统,使之能 提供一下功能: (1) 系统以菜单方式工作; (2) 课程信息和学生信息的录入功能(课程信息有文件保 存)----输入; (3) 课程信息浏览功能----输出; (4) 查询功能(至少一种查询方式)---算法; (5) 按学分查询; (6) 某门课程学生选修情况(可选项)。 [提示] 数据结构可用结构体,包括课程和选秀两个结构体,其中课程结构 体包括课程编号、课程名称、课程性质、总学时、授课学时、实验或上
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
C语言程序设计学校:中国地址大学学院:工程学院班级序号:05507110学号:20071001448姓名:杨帆指导老师:刘文中C语言程序设计报告一、C语言课程设计的目的:高级语言课程设计是学习完《高级语言程序设计》课程后进行的一次全面的综合性上机实验。
其目的在于为同学提供了一个既动手又动脑,独立实践的机会,将课本上的理论知识和实际有机的结合起来,锻炼同学的分析解决实际问题的能力。
提高学生适应实际,实践编程的能力。
二、题目学生选修课程系统设计假定有n门课程,每门课程有课程编号、课程名称、课程性质、总学时、授课学时、实验或商机学时、血粉、开课学期等信息,学生可按要求(如总学分不得少于60)自由选课。
1、要求:试设计一个选修课程系统,使之能提供以下功能:(1)系统以菜单方式工作。
(2)课程信息和学生选课信息输入功能(课程信息用文件保存)——输入。
(3)课程信息浏览功能——输出。
(4)查询功能(至少一种查询方式)——算法。
(5)按学分查询。
(6)某门课程学生选修情况(可选项)。
2、分析:由于题目要求将学生的选课信息用结构体形式输入,并写入文件中,所以应提供文件的输入输出等操作:在过程中需有浏览、插入、修改、查找、删除学生选课信息等操作,顾应分别建立个功能模块;另外还应提供键盘式选择菜单实现程序运行。
3、总体设计:根据题目要求,可以将系统分为六个模块:1)系统以菜单方式工作模块;2)课程信息与学生选课信息录入功能模块;3)课程信息浏览功能模块;4)查询模块;5)按学分查询模块;6)某些课程学生选修情况模块。
4详细设计:#include <stdio.h>#include <stdlib.h> 主流程图:#include <string.h> Arraytypedef 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 *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("%d %s %s %d %d %d %d %d",&num,&name,&kind,&stime,&ttime,&eti me,&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;elsetail->next=p;tail=p;scanf("%d %s %s %d %d %d %d%d",&num,&name,&kind,&stime,&ttime,&eti me,&score,&term);}tail->next=NULL;return head;}void savefile(SUB *head) Array {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%7d\n",p->num,p->name,p->kind,p ->stime,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%7d\n",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)fprintf(fp,"%5d%12s%9s%9d%9d%11d%11d%7d\n",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");for(ptr=head;ptr;ptr=ptr->next)printf("%5d%12s%9s%9d%9d%11d%11d%7d\n",ptr->num,ptr->name,ptr->kind,ptr->stime,ptr->ttime,ptr->etime,ptr->score,ptr->term);}{int a,num;int t=1;char type[10];char ch='a',ch1;SUB *ptr;while(ch!=' '){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){printf("%5d%12s%9s%9d%9d%11d%11d%7d\n",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("课程编号课程名称课程性质总学时授课学时实践或上机学时学分开课学期\n");for(ptr=head;ptr;ptr=ptr->next)if(ptr->score==num){printf("%5d%12s%9s%9d%9d%11d%11d%7d\n",ptr->num,ptr->name,ptr->kind, ptr->stime,ptr->ttime,ptr->etime,ptr->score,ptr->term);t=0;}if(t) printf("未找到!\n");t=1;}printf("继续查找请按回车键,结束请按空格键:\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");scanf("%d%s%s%d%d%d%d%d",&subj->num,subj->name,subj->kind,&subj->st ime,&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->next=subj;subj->next=NULL;break;}}printf("继续插入请按回车,结束请按空格:\n");ch1=getchar(); //将回车键赋给CH1,否则subj->term输完后输入的回车键会赋给CH,因此用CH1填补。