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

合集下载

C语言学生选修课程系统设计

C语言学生选修课程系统设计

《高级语言程序设计》课程设计说明书设计题目:学生选修课程系统设计目录1.设计目的…………………….p22 .总体设计……………………p33.详细设计…………………….p44.调试与测试………………….p55.源程序清单与执行结果…….p66.建议和体会………………….p21一.设计目的(1)基本掌握面向过程程序设计的基本思路和方法;(2)达到熟练掌握C语言的基本知识和技能;(3)能够利用所学的基本知识和技能,解决简单的程序设计问题程序功能:(1)输入信息,密码保护(2)浏览信息(3)查询信息,提供两种查询方式(4)统计选课情况(5)进入选课操作(6)退出选课系统二.总体设计设计的流程图如下三、详细设计1、输入初始的课程信息:课程信息用文件保存,包括课程编号,课程名称,课程性质,总学时,授课学时,实验或上机学时,学分,开课学期等相关信息。

在输入课程信息前要先输入管理员密码,从而限制权限;2、浏览模块:按照指示就可以找到课程编号,课程名称,课程性质,总学时,授课学时,实验或上机学时,学分,开课学期等相关信息;3、查询模块:按照指示可以选择通过学分查询信息,或者选择课程性质来查询信息;4、选择模块:通过输入学号和课程编号来选择所修课程,并有统计功能;5、查阅模块:选择主菜单的选项,可以了解统计所选课程的人数;6、退出模块:在主菜单选择“0”退出选课系统。

四:调试与测试问题一、查询模块:其中包括课程编号,课程名称,课程性质,总学时,授课学时,实验或上机学时,学分,开课学期等相关信息;当输入学分或者课程性质后,系统进行判断时,提示“输入错误!请重新输入!”解决办法及步骤:1、浏览所有课程中的学分是否为你所输入的值。

2、浏览所有课程中的课程性质是否有存在你所输入的值。

3、输出用于循环检查语句中的课程,发现乱码。

4、仔细分析乱码的原因,最后发现是变量的类型错误,错将课程性质的结构体指针变量定义为了其他类型的指针变量。

C语言课程设计学生选修课系统设计

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

C语言课程设计报告-选课管理系统

C语言课程设计报告-选课管理系统

课程设计题目:选课管理系统《1》选课管理系统要求:•学生选课信息的添加(学生选课信息包括学生学号、课程名称、学分)•学生选课信息的删除•学生选课信息查询(查询每个学生的选课信息,每个学生选课的总学分,选具体某门课程(课程名输入)的学生名单))•《2》实现思路个人信息用结构体定义,解决的方案可以用结构体数组,或是链表作为临时数据处理,用文件来存储数据。

注意数据定义的数据类型,用函数实现相应的功能,然后在主程序中调用,程序运行的时候用菜单选择功能,然后进行相关操作。

1---------选课信息的添加------------2---------选课信息的删除------------3---------选课信息的修改------------4---------选课信息的查询------------5---------从文件读入学生信息--------------6---------------删除文件中学生信息-------------7---------------保存学生信息--------------------8----------------退出------------------------------《3》实验总结(分析程序的得与失)这个课题是设计一个成绩管理系统,该系统能够较好的管理好学生的成绩,也拥有比较完善的功能。

在编写过程中,我逐步的了解了程序模块化设计的思想含义。

在整个程序设计的过程中语法的错误还是比较容易检查的,但是对于那些逻辑思维的问题方面的缺陷不易查出,因此常常出现系统提示没有错误但是仍然不能够正常运行的境况,尽管有很多不足之处,但我在整个系统程序设计的过程中,我可以感受到自己对C语言有了一定的掌握,对整体的把握度也提高了很多。

《4》心得体会通过这周的编程我发现了自己的一些不足,在编写时经常犯一些低级错误,由于自己的马虎而浪费了不少时间。

在不知如何进行的时候有一种不自信,总想别人正在做什么,这些不足既然被发现就得在以后的做事中注意,争取改掉。

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

C语言程序设计报告—学生选修课程系统
p->totalperiod=totalபைடு நூலகம்eriod;
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语言程序设计报告—学生选修课程系统

中南民族大学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语言大型作业实践报告计算机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语言课程设计学生选课管理系统实验报告

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语言——学生选修课程系统

C语言——学生选修课程系统

中国地质大学C课程设计报告学生选修课程系统姓名 c语言学号 201210006qq 专业地质学所在院系地球科学学院教师姓名 ### 日期: 2014 年 12 月 27 日评语对课程报告的评语:总成绩:评阅人签名:目录一、实习感悟 (1)二、课程要求 (2)三、各个模块的流程图 (3)四、源程序 (8)五、调试结果 (18)六、程序有待改进的地方 (23)(一)实习感悟经过这次只有32个学时c语言实习,我学会了许多,c语言实习是一个枯燥乏味但有充满了乐趣的过程,你会为一个小小的错误而坐立不安;你会为一个下午的编程却错误连篇而痛心疾首;但也有稍微改动一个符号的错误,瞬间眼前几十个错误就灰飞烟灭的心灵舒畅。

这次实习让我加深了对C语言的了解,而不纯粹是课本中学到的那些理论,平时乏味的课程,通过自己动手亲自编写,变的生动有趣,而在自己动手的过程中,出现的问题很多,比理论要难的多,当一个程序写完以后,经常会有很多错误而没法解决。

我就曾因为进行浏览操作时,缺失一个读出文件的函数而苦恼不已,最后还是在助教帮助下找到这个运行时出现的错误。

我实习的内容是编一个学生选修课程系统。

看似简单的事情对于我来说是个多么大的挑战,一年之前学习过的c语言早就忘得差不多了,于是我只好重新回忆以前学过的c语言知识。

虽然我们在一年前c语言上课时曾经实习过,但那只不过是c语言的简单的函数的实习,是让我们更好的熟悉书本的每一个函数和各种符号的正确使用。

所以我们对c语言的理解仅仅停留在函数阶段,而我们这次实习却是各种函数的使用,很多时候都是和文件的使用结合在一起,而恰恰我对文件的使用不太熟悉,只好硬着头皮看了文件这个模块一个下午,对文件的输入与输出有了基本的了解。

32个学时的实习其实只有8大节课,时间十分的短。

老师并没有给我们太多的解析,也容不得我们自己用太多的时间去考虑,只是给了我们一个书本的模块,让我们按照其方式去编一个程序。

这次的实习虽然并没有让我成为一位编程序的高手,但却让我掌握了许多。

c语言课程设计学生选课系统设计

c语言课程设计学生选课系统设计

c语言课程设计学生选课系统设计一、课程目标知识目标:1. 理解C语言的基本语法和结构,掌握数组、指针、函数等基本概念;2. 学会使用结构体、文件操作等C语言特性进行数据组织和存储;3. 掌握面向过程编程思想,能够运用C语言设计简单的学生选课系统。

技能目标:1. 能够运用结构化编程方法,编写模块化的C语言代码;2. 学会使用C语言进行简单的数据输入、处理和输出;3. 能够运用调试工具,分析并解决程序中的错误。

情感态度价值观目标:1. 培养学生对计算机编程的兴趣,激发自主学习编程的积极性;2. 培养学生的团队合作意识,学会在团队中发挥个人优势,共同解决问题;3. 培养学生严谨、细心的编程习惯,认识到编程对培养逻辑思维能力和解决问题能力的重要性。

课程性质:本课程为C语言程序设计课程的实践环节,以学生选课系统设计为主题,结合C语言编程知识,培养学生的实际编程能力和解决问题的能力。

学生特点:学生已具备一定的C语言基础,对编程有一定了解,但实际操作能力有待提高。

教学要求:结合学生特点和课程性质,将课程目标分解为具体的学习成果,注重实践操作,强化编程能力和团队协作能力的培养。

在教学过程中,关注学生个体差异,提供个性化指导,确保课程目标的达成。

二、教学内容1. C语言基础知识复习:数组、指针、函数、结构体、文件操作等基本概念和用法。

教材章节:第三章数组和第四章函数。

2. 面向过程编程思想:顺序结构、分支结构、循环结构等控制结构在实际编程中的应用。

教材章节:第五章控制结构。

3. 学生选课系统需求分析:了解系统功能、模块划分,明确编程目标和任务。

教材章节:项目实训部分。

4. 学生选课系统设计:模块化设计、数据结构设计、界面设计等。

教材章节:项目实训部分。

5. 编程实践:根据设计文档,编写C语言代码实现学生选课系统。

教材章节:项目实训部分。

6. 调试与测试:使用调试工具,对程序进行调试和测试,确保系统功能的正确性和稳定性。

c课程设计学生选课系统程序设计报告

c课程设计学生选课系统程序设计报告

c++课程设计--学生选课系统程序设计报告计算机科学与技术学院学生选课系统程序设计报告班级: 1003专业:嵌入式软件指导教师:吴克立杨素娣学号: 211011016姓名:李倩倩2010年2月29日目录一.设计目的.....................................二.总体设计.....................................三.详细设计.....................................1.界面设计...................................2.课程信息设计............................3.学生信息设计............................4.选课设计...................................四.测试与调试.................................五.心得体会....................................一.设计目的网上选课系统是针对在校学生和教师使用,从学生的角度来说,由于学校教学制度的改革,现在大部分高等院校开始实行的是学生的自主选课模式,传统的教学模式(学生按照学校安排好的课程上课)已经不能适应新型的教学手段,如果仍然通过纸上的方式选课,一方面浪费的大量的人力、物力资源,另一方面浪费时间以及在人为的统计过程中不可避免出现的差错等情况。

随着学校规模的不断扩大,专业、班级、学生的数量急剧增加,有关学生选课的各种信息量也成倍增长,而目前许多高校的学生选课管理仍停留在复杂的人工操作上,重复工作较多,工作量大,效率低,这种弊端会越来越多的暴露出来。

因此,利用网络,使学生只要在计算机前输入自己的个人选课信息即可完成原来几倍的作业量。

从教师的角度来说,同样是节省了大量的工作量,由于教师提出代课申请完成课程发布的工作较学生选课而言更加的复杂,因此通过网上进行课程发布能大幅度的减少教师的工作量,减少错误的发生几率。

C语言课程设计--学生选修课系统

C语言课程设计--学生选修课系统

C语言课程设计--学生选修课系统内蒙古科技大学本科生课程设计说明书题目:C语言课程设计——学生选修课管理学生姓名:***学号:**********专业:计算机科学与技术班级:13-计算机2班指导教师:***内蒙古科技大学课程设计论文2013年12月31日内蒙古科技大学课程设计任务书目录课程设计任务书 (V)目录 (V)第一部分:程序总体设计思路 (3)第二部分:程序功能划分、图示及流程图 (3)函数划分 (3)总体设计 (4)课程选择函数流程图 (5)课程新增函数流程图 (6)第三部分:程序设计数据及运行结果 (7)第四部分:心得体会 (12)第五部分:附录(参考文献及源程序) (12)主函数部分:main() (14)菜单函数:void index() (14)登陆界面函数:void login() (15)学生登陆界面函数:void stu_login() (17)管理员登陆界面函数:void man_login() (16)退出界面函数:void bye_sys() (16)学生课程选择函数:void c_select() (18)课程增加函数:void c_add() (21)课程删除函数:void c_delete() (22)学生课程查询函数:void c_search() (25)管理员课程查询函数:void c_search() (28)管理员课程浏览函数:void c_view() (31)学生课程浏览函数:void c_view() (34)第一部分:程序总体设计思路由于C语言是面对过程的语言,故我的设计思路是根据目标程序运行的过程来编写的。

具体设计思路如下:程序的需求是设计学生选修课管理系统,对选修课程能够进行录入和修改操作等,要求有菜单界面和退出功能。

首先,考虑到程序的数据输入,可以设置一个管理员登陆选项,通过该选项进入管理员界面,进行选修课的录入和修改操作,最后将录入的课程保存到相应的文件中。

C语言课程设计--学生选课系统实习报告

C语言课程设计--学生选课系统实习报告

C语言上机实习报告院系:班级:姓名:指导老师:2010-8-28至2010-9-4目录一、设计目的 (1)二、设计要求 (2)三、题目及其要求 (2)四、需求分析 (2)五、总体设计 (3)六、详细设计 (3)6.1、主函数 (3)6.2、菜单函数 (4)6.3各模块设计 (7)6.3.1输入函数 (7)6.3.2添加函数 (9)6.3.3修改函数 (12)6.3.4查找函数 (16)6.3.5选择课程 (20)6.3.6删除课程 (23)6.3.7浏览函数 (26)6.3.8退出操作 (27)6.3.9公共函数——保存函数 (28)七、上机实习 (28)八、设计实习心得 (29)九、参考书目 (29)十、学生选课系统与程序 (30)一、设计目的随着信息技术对人类社会进行的全方位渗透,一种新的文化形态——信息时代的计算机文化已经形成。

计算机知识成为当代知识分子结构中不可缺少的重要部分。

C语言是近年来国内外得到迅速推广使用的一种高级语言。

C语言功能丰富,表达能力强,使用灵活方便,应用广,目标程序效率高,可移植性好,既具有高级语言的优点,又具有低级语言的语言特点,因此C语言对我们来说很重要。

学习的目的在于将所学到的东西运用于实践,这样方可在实践中巩固以前所学的理论知识,同时提高自己学习的能力,完善自己掌握的技能,使得我们既能够从实践中强化以前所学的知识,也能让我们在实践中学到更多新的东西,还能锻炼我们的动手能力,这是书本上不能学到的。

此次设计就在于让我们把以往所学运用于实践中,让我们通过对实际生活中的实例进行观察和理论分析后,总结出一套可行的解决方案,然后用编程的方法,把解决方案变为可能。

此次设计,也让我们巩固和加深了对C语言课程的基本知识的理解和掌握,帮助我们掌握C 语言编程和程序调试的基本技能,让我们体验了如何用C语言进行基本的软件设计,同时也提高了我们书写程序说明的能力和用C语言解决实际问题的能力。

C语言课程设计—学生选课系统

C语言课程设计—学生选课系统

武汉理工大学华夏学院课程设计报告书课程名称:C课程设计题目:学生选课系统程序设计系名:信息工程系专业班级:姓名:学号:指导教师:成绩:2016年 3 月4日课程设计任务书学生姓名:专业班级:指导教师:工作单位:设计题目:学生选课系统程序设计初始条件:学生选课系统能提供学生选课,以及学生和课程信息管理等一系列功能。

要求完成的主要任务:(包括课程设计工作量及其技术要求,以及说明书撰写等具体要求)1、任务描述假定有n门课程,每门课程有课程编号,课程名称,课程性质,学时,授课学时,实验或上机学时,学分,开课学期等信息,学生可按要求(如总学分不得少于15)自由选课。

试设计一个选修课程系统,使之能提供以下功能:(1)系统以菜单方式工作(2)课程信息和学生选课信息录入功能(课程信息用文件保存)(3)课程信息浏览功能(4)查询功能(5)按学分查询(6)某门课程学生选修情况(可选项)2、本课程涉及的知识点变量的定义、输入和输出函数、结构体类型的定义、结构体数组、循环语句、选择语句,文件的操作等。

设计报告撰写格式要求:一、课程设计说明书(或报告书)正文内容【设计题目】例如:学生选课系统【开发环境】硬件环境:微机系列,内存在1G以上,软件环境:Microsoft Windows XP 【开发工具】 Microsoft Visual C++ 6.0【完成时间】 2016-2 -29-----2016.3.4【需求分析】分析阐述用户的需要以及要实现的程序应具有什么样的功能。

【系统总体设计】在明确了所要解决的问题后,很自然地就要提出自己解决问题的思路和方案。

让读者了解方案的总体设计和关键技术。

要阐述自己的设计方案,说明为什么要选择或设计这样的方案。

具体包括:系统总的设计思路,功能模块图;使用的设计软硬件环境和开发技术和平台等。

【系统详细设计】在这部分中,应该具有相关关键实现技术(如使用什么库函数,使用什么循环结构等)。

【系统调试和测试】调试:介绍设计过程中遇到的问题和解决方法。

学生选课管理系统c语言程序

学生选课管理系统c语言程序

学生选课管理系统c语言程序随着信息技术的快速发展,学生选课管理系统成为了现代教育管理的重要组成部分。

本文将介绍一个基于C语言编写的学生选课管理系统程序,旨在提供一个简单、高效的选课系统,方便学生和教师进行选课和管理。

一、系统概述学生选课管理系统是一个基于C语言开发的程序,主要实现学生选课和教师管理的功能。

系统采用命令行界面,通过输入指令和参数来完成各种操作。

系统具有良好的用户交互性和数据管理能力,能够满足学生选课和教师管理的需求。

二、系统功能1. 学生选课功能学生可以通过输入选课代码和课程号来选择课程。

系统会根据学生的选择进行验证,并更新学生的选课信息。

学生还可以查询已选课程和退选课程。

2. 教师管理功能教师可以通过输入教师号和密码登录系统,进行课程管理和成绩录入。

教师可以添加、修改和删除课程信息,并录入学生成绩。

系统会对输入的数据进行验证,确保数据的准确性和完整性。

3. 课程查询功能学生和教师可以通过输入课程号或课程名称来查询课程信息。

系统会返回与输入信息匹配的课程列表,并显示相关的课程信息。

4. 成绩查询功能学生可以通过输入学号查询自己的成绩。

系统会返回该学生已选课程的成绩,并计算平均成绩和总学分。

5. 系统管理功能系统管理员可以通过输入管理员账号和密码登录系统,进行系统管理操作。

管理员可以添加、修改和删除学生、教师和课程信息,并进行数据备份和恢复操作。

三、系统设计1. 数据结构系统使用链表和数组来存储学生、教师和课程信息。

链表用于存储学生和教师的基本信息,数组用于存储课程信息和成绩数据。

通过合理的数据结构设计,系统可以高效地进行数据的增删改查操作。

2. 模块设计系统分为学生模块、教师模块和管理员模块。

每个模块都有相应的功能和操作权限。

学生模块主要实现选课和成绩查询功能,教师模块主要实现课程管理和成绩录入功能,管理员模块主要实现系统管理功能。

3. 界面设计系统采用命令行界面,通过输入指令和参数来完成各种操作。

C语言课程设计报告-学生选课系统

C语言课程设计报告-学生选课系统

X X X学校C程序设计课程设计报告选题名称:学生选修课程系统设计系(院):计算机工程系专业:嵌入式软件系统设计方向班级:嵌入式1091 姓名: XXX 学号: XXXXXXXXXX指导教师: XXX 学年学期:2008 ~ 2009 学年第 1 学期2009 年12 月28 日设计任务书年月日摘要:C语言课程设计和现代计算机技术的实际应用相结合,是我们在本阶段学完理论课程之后对自己该方面的能力的一次很好的检验,从开始的算法思路到运行调试后的美观的图形界面以及另人兴奋的可用程序,都是一个很好的学习和锻炼的过程。

使我们巩固了原有的理论知识,培养了我们灵活运用和组合集成所学过知识及技能来分析、解决实际问题的能力。

使我们体会到自身知识和能力能在实际中的应用和发挥。

不但可以激发创新意识,还可以开发创造能力、培养沟通能力。

这次学生选修课系统管理设计时间虽然仅有一个星期,但确实使我受益非浅。

通过学生选修课系统管理设计我丰富了计算机操作经验,更加深了对C语言的了解,熟悉了其环境,更增强了对Turbo C的使用技巧。

C语言是在国内外广泛使用的一种计算机语言。

语言功能丰富、表达能力强、使用灵活方便、既具有高级语言的优点,又具有低级语言的许多特点,适合编写系统软件。

同时,我觉得C语言应该是操作和理论相结合的课程,在不断地编写中去思考,两者是不可分割的。

我们在编写一个较大的程序时应该把它分开成几个小程序来看,这样会容易得多。

关键词:学生选修课系统管理;C语言课程设计;计算机技术;模块化程序设计;信息录入;浏览信息;选课;查询目录1.设计目的 (5)2.总体设计 (5)2.1首先实现学生选修课程系统主菜单 (5)2.2其次实现模块化语句设计 (7)总结 (11)致谢 (12)参考文献 (13)C语言课程设计报告1.设计目的设计学生选修课程管理系统:假定有n门课程,每门课程有课程编号,课程名称,课程性质,总学时,授课学时,实验或上机学时,学分,开课学期等信息,学生可按要求(如总学分不得少于60)自由选课。

学生选修课程系统设计(C语言)

学生选修课程系统设计(C语言)

课程设计题目:学生选修课程系统课程设计内容:用C语言编写程序完成以下任务:(1)录入课程信息(课程信息包括课程编号、课程名、学时和学分),并保存在lessons.txt文件中,课程按课程编号有序。

(2)添加课程信息:添加前首先查找该门课是否存在,若不存在则按照课程编号大小插入到适当位置。

(3)选修一门课程:需要给出学号和课程编号,如果课程编号不存在则重新输入,直到输入正确为止,并将学号和相应的课程编号存入SelectInfo.txt文件中。

(4)显示出所有学生的选课情况。

课程设计要求:1.贯彻结构化程序设计思想。

2.用户界面友好,功能明确,操作方便;可以加以其它功能或修饰。

3.用户界面中的菜单至少应包括“输入课程信息”、“添加课程信息”、“选课及显示”、“退出”4项。

4.代码应适当缩进,并给出必要的注释,以增强程序的可读性。

#include<stdio.h>#include<stdlib.h>#include<string.h>#include<conio.h>int count = 0;int cou = 0;int choose = 0; //用于统计数组个数/*================定义函数===============*/void allput(); //把数组整体排序输出void insert(); //插入新课程void search(); //搜索指定课程void delete_(); //删除指定课程void select(); //选课void change(); //修改指定课程void baocun(); //保存,把修改后的数组重新装入文件void into(); //验证密码void apply(); //申请密码struct subject_list{char num[15]; //装课程编号char name[30]; //装课程名称int xueshi;float xuefen; //分别装学时、学分}sub[100];struct secret{char xuehao[15];char sec[15];}stu[1000];/*================================主函数================================*/void main(){int i=0;FILE *fp,*fpp;if((fpp=fopen("e:\\Secret.txt","r")) == NULL){printf("File open error!\n");exit(0);}while(! feof(fpp)){fscanf(fpp,"%s%s",stu[i].xuehao,stu[i].sec);i++;cou++; //计数};system("color df");/*—————————————————————验证、申请密码——————————————————--——-*/printf("\n\n\n------------------------------ 请通过密码进入------------------------------\n\n\n");do{printf(" 1:进入系统;2:申请密码;0:退出\n");printf(" 请选择功能:");scanf("%d",&choose);printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");if(choose<0){printf("输入错误!\n");exit(0);}switch(choose){case 1: into(); //===========〉引入密码验证函数if(fclose(fpp)){printf("Can not close the file!\n"); //====〉关闭文件exit(0);}break;case 2: apply(); break; //===========〉引入apply 函数case 0:exit(0);default:printf("\n 请重新输入!\n");break;}}while(choose!=0);if((fp=fopen("e:\\LessonInfo.txt","r")) == NULL){printf("File open error!\n");exit(0);}/* 把文件内容赋给数组*/i = 0;while(! feof(fp)){fscanf(fp,"%s%s%d%f",sub[i].num,sub[i].name,&sub[i].xueshi,&sub[i].xuefen); i++;count++; //计数};if(fclose(fp)){printf("Can not close the file!\n"); //====〉关闭文件exit(0);}printf("\n\n\n\n\n\n\n\n\n\n\t 正在启动系统>>>> >>>> >>>>\t\n\n\n\n\n\n\n\n\n\n");for(i=0;i<100000000;i++);system("cls");system("color 1f");/*———————————————————主体框架——系统操作———————————————————————*/do{system("cls");printf("\n\n");printf("==============================欢迎进入学生选课系统==============================\n");printf(" __________________学生选课系统功能选项:__________________ \n");printf(" | 1. 看所有课程信息|\n");printf(" | 2. 搜索指定课程信息|\n");printf(" | 3. 添加课程信息|\n");printf(" | 4. 删除课程信息|\n");printf(" | 5. 修改课程信息|\n");printf(" | 6. 选课|\n");printf(" |________________________7. 退出___________________________|\n");printf("*******************************************************************************\n ");printf("请选择功能:");scanf("%d",&choose);printf("--------------------------------------\n");/* 建立分支选择功能选项*/switch(choose){case 1: allput(); break; //=================〉引用函数排序输出case 2: search(); break; //=================〉引用搜索函数case 3: insert(); break; //=================〉引用插入函数case 4: delete_(); break; //=================〉引用删除函数case 5: change(); break; //=================〉引用函数修改内容case 6: select(); break; //=================〉引用选课函数case 7: printf("谢谢使用!再见!\n"); exit(0); //=================〉退出default: printf("请重新输入\n"); break;}printf("--------------------------------------------------------------------------------\n"); printf(" 按任意键返回首层\n");getch();}while(choose != 7);}/*=============把数组整体排序输出================*/void allput(){int i,j,xueshi;char num[15],name[15];float xuefen;/* 冒泡排序*/for(i=1;i<count;i++)for(j=0;j<count-1;j++)if(strcmp(sub[j].num,sub[j+1].num)>0){strcpy(num,sub[i].num);strcpy(name,sub[i].name);xueshi = sub[i].xueshi;xuefen = sub[i].xuefen;strcpy(sub[i].num,sub[i+1].num);strcpy(sub[i].name,sub[i+1].name);sub[i].xueshi = sub[i+1].xueshi;sub[i].xuefen = sub[i+1].xuefen;strcpy(sub[i+1].num,num);strcpy(sub[i+1].name,name);sub[i+1].xueshi = xueshi;sub[i+1].xuefen = xuefen;}/* 输出查找到的信息*/printf("课程编号\t课程名称\t学时\t学分\n");for(i=0;i<count;i++)printf("%s\t%s\t%d\t%.1f\n",sub[i].num,sub[i].name,sub[i].xueshi,sub[i].xuefen) ;baocun(); //把排序后的数组重新写入文件}/*========================================查看指定课程信息=====================================*/void search(){char num[15];int i,flag=0;do{printf("请输入课程编号:");scanf("%s",num);for(i=0;i<count;i++){if(strcmp(num,sub[i].num) == 0){flag = 1;break;}}/* 输出查找到的信息*/if(flag){printf("课程编号\t课程名称\t学时\t学分\n");printf("%s\t%s\t%d\t%.1f\n",sub[i].num,sub[i].name,sub[i].xueshi,sub[i].xuefen) ;}else{printf("无此课程!1:重新输入;2.返回\n");printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf("请输入:");scanf("%d",&choose);printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");}if(choose!=1) return;}while(flag==0);}/*=============================================选课===========================================*/void select(){char stu[15],num_[15];int i,flag=0;FILE *fp_;fp_=fopen("e:\\SelectInfo.txt","a");if(fp_== NULL){printf("File open error!\n");exit(0);}do{printf("请输入学号:");scanf("%s",stu);printf("请输入课程编号:");scanf("%s",num_);/* 判断要选课程是否存在*/for(i=0;i<count;i++){if(strcmp(num_,sub[i].num) == 0){//strcpy(name,sub[i].name)flag = 1;break;}}if(flag){fprintf(fp_,"%s %s %s\n",stu,num_,sub[i].name);printf("选课成功!\n");/* 关闭文件*/if(fclose(fp_)){printf("Can not close the file!\n");exit(0);}}else{printf("无此课程!1:重新输入;2.返回\n");printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf("请输入:");scanf("%d",&choose);printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");}if(choose!=1) return;}while(flag==0);}/*=======================================添加课程=============================================*/void insert(){int i,j,flag=0;char num[15];do{flag = 0;printf("请输入课程编号:");scanf("%s",num);/* 判断要添加课程是否存在*/for(i=0;i<count;i++){if(strcmp(num,sub[i].num) == 0){flag = 1;break;}}if(flag){printf("此课程已存在!1:重新输入;2.返回\n");printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf("请输入:");scanf("%d",&choose);printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");if(choose!=1) return;}else{j=count;for(i=0;i<count;i++){if(strcmp(num,sub[i].num)>0) continue;strcpy(sub[j].num,sub[j-1].num); //后一项覆盖前一项strcpy(sub[j].name,sub[j-1].name);sub[j].xueshi = sub[j-1].xueshi;sub[j].xuefen = sub[j-1].xuefen;j--;}/* 输入要添加的信息*/strcpy(sub[j].num,num);printf("请输入课程名称:");scanf("%s",sub[j].name);printf("请输入学时:");scanf("%d",&sub[j].xueshi);printf("请输入学分:");scanf("%f",&sub[j].xuefen);count++;baocun();printf("添加成功!\n");}}while(flag==1);}/*=======================================删除课程===============================================*/ void delete_(){char num[15];int i,j,flag=0;do{printf("请输入课程编号:");scanf("%s",num);for(i=0;i<count;i++)if(strcmp(num,sub[i].num) == 0){flag = 1;break;}if(flag){for(j=i;j<count-1;j++){strcpy(sub[j].num,sub[j+1].num); //后一项覆盖前一项strcpy(sub[j].name,sub[j+1].name);sub[j].xueshi = sub[j+1].xueshi;sub[j].xuefen = sub[j+1].xuefen;}count--;baocun(); //引用保存函数printf("删除成功!\n");}else{printf("无此课程!1:重新输入;2:返回\n");printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf("请输入:");scanf("%d",&choose);printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");}if(choose!=1) return;}while(flag==0);}/*===========================================修改课程==========================================*/void change(){char num[15];int i,flag=0;do{printf("请输入课程编号:");scanf("%s",num);/* 判断要修改课程是否存在*/for(i=0;i<count;i++)if(strcmp(num,sub[i].num) == 0){flag = 1;break;}if(flag){printf("请输入修改后的课程名称:");scanf("%s",sub[i].name);printf("请输入学时:");scanf("%d",&sub[i].xueshi);printf("请输入学分:");scanf("%f",&sub[i].xuefen);baocun(); //引用排序函数,重新写入文件printf("修改成功!\n");}else{printf("无此课程!1:重新输入;2.返回\n");printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf("请输入:");scanf("%d",&choose);printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); }if(choose!=1) return;}while(flag==0);}/*============================================保存=============================================*/void baocun(){int i;FILE *fpp;fpp = fopen("e:\\LessonInfo.txt","w");/* 把数组装入文件*/for(i=0;i<count-1;i++)fprintf(fpp,"%s %s %d %.1f\n",sub[i].num,sub[i].name,sub[i].xueshi,sub[i].xuefen);fprintf(fpp,"%s %s %d %.1f",sub[i].num,sub[i].name,sub[i].xueshi,sub[i].xuefen);/* 关闭文件*/if(fclose(fpp)){printf("Can not close the file!\n");exit(0);}}/*====================通过密码进入后面的程序=====================*/void into(){int i=0;char xueh[15],secret[15];do{printf(" 请输入学号:");scanf("%s",xueh);printf(" 请输入密码:");scanf("%s",secret);for(i=0;i<cou;i++)if(strcmp(xueh,stu[i].xuehao)==0&&strcmp(secret,stu[i].sec)==0){choose = 0;system("cls");return;}//printf("--------------------------------------------------------------------------------\n"); printf("\n 密码错误!1:重新输入;2 :返回\n\n");printf(" 请输入:");scanf("%d",&choose);printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~\n");//if(choose<0) { printf("输入错误!\n"); exit(0);}if(choose!=1) return;}while(1);}/*==========================申请密码=====================*/ void apply(){FILE *fqq;int i=0,flag = 0;char xuehao[15];do{flag = 0;printf("\n 请输入学号:");scanf("%s",xuehao);for(i=0;i<cou;i++)if(strcmp(xuehao,stu[i].xuehao)==0)flag = 1;if(flag!=1) break;//printf("--------------------------------------------------------------------------------\n"); printf("\n 学号已存在!1:重新输入;2:返回\n");printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf(" 请输入:");scanf("%d",&choose);printf("--------------------------------------------------------------------------------\n");if(choose<0) { printf("输入错误!"); exit(0); }if(choose!=1) return;}while(flag);fqq=fopen("e:\\Secret.txt","a+");printf(" 请输入密码:");scanf("%s",stu[i].sec);strcpy(stu[i].xuehao,xuehao);cou++;fprintf(fqq,"\n%s %s",xuehao,stu[i].sec);if(fclose(fqq)){printf("Can not close the file!\n");exit(0);}printf("--------------------------------------------------------------------------------\n");printf(" 申请成功!是否立即进入:1:进入;2:退出\n");printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf(" 请输入:");scanf("%d",&choose);printf("--------------------------------------------------------------------------------\n");switch (choose){case 1:into();break;default:if(fclose(fqq))printf("Can not close the file!\n");exit(0);}}。

C语言实现学生选修课程系统设计

C语言实现学生选修课程系统设计

C语⾔实现学⽣选修课程系统设计本⽂实例为⼤家分享了C语⾔学⽣选修课程系统的具体代码,供⼤家参考,具体内容如下我编程的时间不长,所以这⾥⾯肯定有⼀些错误,或者存在更好的解决⽅案,欢迎⼤神上课!谢谢!ps:寻找⼀起学习的⼩伙伴!代码:/**********************************主题:学⽣选修课程系统设计**设计要求:*1.添加功能:程序能够任意添加课程和学⽣记录,可提供选择界⾯供⽤户选择所需要添加的类别,要求编号要唯⼀,如果添加了重复编号的记录是,则提⽰数据添加重复并取消添加。

*2.查询功能:可根据编号、姓名等信息对已添加的同学和课程记录进⾏查询,如果未找到,给出相应的提⽰信息,如果找到,则显⽰相应的记录信息。

*3.显⽰功能:可显⽰当前系统中所有学⽣和课程的记录,每条记录占据⼀⾏。

*4.编辑功能:可根据查询结果对相应的记录进⾏修改,修改时注意编号的唯⼀性。

*5.删除功能:主要实现对已添加的学⽣和课程记录进⾏删除。

如果当前系统中没有对应的记录,则提⽰“记录为空!”并返回操作。

*6.统计功能:能根据多种参数进⾏统计。

能统计学⽣⼈数、课程门数、选修某门课程的学⽣的相关信息。

**********************************//** Verson:2.0(basic)** History: 完成课程信息的录⼊,查询等操作;完成选课功能(2017-05-05 20:30:00-01:20:00)** Author:universes***********************************//** Verson:1.9** History:完成了学⽣信息的查询操作 (2017-05-04 22:00:32-01:11:00)** Author:universes**********************************//** Verson:1.5** HIstory2:添加查重功能(2017-05-02 23:39:19-01:06:05)* History1:完成了⽤户对课程和学⽣信息的添加操作(没有查重功能)(2017-05-02 22:06:13-23:39:19)** Author:universes**********************************//** Verson:1.0** History:完成了⽤户的选择功能框架(2017-04-19 22:06:13-22:40:47)** Author:universes**********************************/#include <stdio.h>#include <malloc.h>#include <stdlib.h>#include <string.h>#define SIZE_STU 10#define SIZE_COU 10#define SIZE_SEL 10//////////////函数声明部分void home(void);void stu_operate(void);void cou_operate(void);void statistic(void);void choose(void);void delete_sel(int);//--学⽣信息部分:void input_stu(void);void search_stu(void);void search_stu_id(void);void search_stu_name(void);void show_stu(void);void edit_stu(void);void renew_stu(void);void delete_stu(void);//--课程信息部分:void show_cou(void);void edit_cou(void);void renew_cou(void);void delete_cou(void);/*学⽣信息结构体*/struct student_info {char stu_ID[9];char stu_name[5];char sex[9];char age[9];char collage[9];char grade[9];char contact[9];}stu[SIZE_STU];/*课程信息结构体*/struct course_info {char course_ID[9];char course_name[9];char property[9];char period[9];char credit[9];char time[9];int people;}cou[SIZE_COU];/*选课记录结构体*/struct select {int s;//存放学⽣信息的数组下标int c;//存放课程信息的数组下标}sel[SIZE_SEL];//全局变量i,j,x分别是学⽣,课程,选课信息数组下标int i = -1;int j = -1;int x = -1;int main(void){//进⼊欢迎界⾯home();return 0;}//欢迎界⾯void home(void) {printf("\n-------------------------欢迎进⼊选课系统!----------------------"); int h;printf("\n\n 请选择你要进⾏的操作:");printf("\n\n 1.学⽣操作");printf("\n 2.课程操作");printf("\n 3.开始选课");printf("\n 4.选课统计");printf("\n 5.退出系统");printf("\n ");printf("\n 请输⼊:");scanf("%d",&h);system("cls");switch(h){case 1:stu_operate();break;case 2:cou_operate();break;case 3:choose();break;case 4:statistic();break;default:system("cls");printf("BYE!");break;}}/*开始选课*/void choose(void){char stu_id[10],cou_id[10];printf("\n-------------------------欢迎进⼊选课系统!----------------------"); //输⼊选课学⽣信息printf("\n\n 请输⼊选课⼈学号:");fflush(stdin);scanf("%s",stu_id);int h,flag = 0;for(h = 0;h <= i;h++){} else {flag = 1;}}if(flag||i==-1){printf("\n 不存在此学号\n");system("pause");system("cls");home();}//录⼊姓名信息x++;sel[x].s = h;//输⼊课程信息printf("\n\n 请输⼊选修课程号:");fflush(stdin);scanf("%s",cou_id);flag = 0;for(h = 0;h <= j;h++){if(strcmp(cou[h].course_ID,cou_id)==0){flag = 0;break;} else {flag = 1;}}if(flag||j==-1){printf("\n 不存在此课程号\n");x--;system("pause");system("cls");home();}//录⼊课程信息sel[x].c = h;cou[h].people++;printf("\n 录⼊成功!\n");system("pause");system("cls");home();}/*删除选课记录*/void delete_sel(int q){//删除第q+1条记录/*注意!本函数没有将x减1,请在函数外⼿动减1(考虑外层函数循环的需要)*/ int h;cou[sel[q].c].people--;for(h = q;q < x;h++){q++;sel[h].c = sel[q].c;sel[h].s = sel[q].s;}}//对学⽣记录进⾏操作void stu_operate(void) {printf("\n-------------------------欢迎进⼊选课系统!----------------------");printf("\n\n 请选择你要对学⽣记录进⾏的操作:");printf("\n\n 1.添加");printf("\n 2.查询");printf("\n 3.显⽰");printf("\n 4.返回主页⾯");printf("\n ");printf("\n 请输⼊:");int i;scanf("%d",&i);system("cls");switch(i){case 1://添加学⽣信息input_stu();break;case 2://查询学⽣信息search_stu();break;case 3://显⽰所有学⽣信息show_stu();break;case 4:home();break;}}//对课程记录进⾏操作void cou_operate(void) {printf("\n-------------------------欢迎进⼊选课系统!----------------------");printf("\n\n 请选择你要对课程记录进⾏的操作:");printf("\n\n 1.添加");printf("\n 2.查询");printf("\n 请输⼊:");int i;scanf("%d",&i);system("cls");switch(i){case 1:input_cou();break;case 2:search_cou();break;case 3:show_cou();case 4:home();break;}}//选课信息统计记录void statistic(void){printf("\n-------------------------欢迎进⼊选课系统!----------------------");printf("\n\n 共有学⽣信息:%d 条",i+1);printf("\n 共有课程信息:%d 条",j+1);if(x == -1){printf("\n 选课记录:0 条");printf("\n\n ");system("pause");system("cls");home();} else {printf("\n\n 选课记录 %d 条:",x+1);int m;for(m = 0;m <= x;m++){printf("\n ================");printf("\n 第%d条",m+1);printf("\n 学⽣学号:%s",stu[sel[m].s].stu_ID);printf("\n 学⽣姓名:%s",stu[sel[m].s].stu_name);printf("\n 课程号:%s",cou[sel[m].c].course_ID);printf("\n 课程名:%s",cou[sel[m].c].course_name);}printf("\n\n ");system("pause");system("cls");home();}}//--------------------------------------学⽣信息插⼊--------------------------------------void input_stu(void){char flag;FILE * fp;//--判断⽂件是否为空fp = fopen("student.txt","r+");flag = fgetc(fp);if(flag==EOF){fprintf(fp,"学号\t姓名\t性别\t年龄\t系别\t班级\t联系⽅式\n");}fclose(fp);//--fp = fopen("student.txt","a+");if(fp == NULL){printf("打开⽂件失败!");system("cls");stu_operate();}printf("学号\t姓名\t性别\t年龄\t系别\t班级\t联系⽅式\n");while(1){i++;scanf("%s %s %s %s %s %s %s",&stu[i].stu_ID,&stu[i].stu_name,&stu[i].sex,&stu[i].age,&stu[i].collage,&stu[i].grade,&stu[i].contact);//--数据查重int h;for(h = 0;h < i;h++){if(i == 0) break;//第⼀条数据不需要查重if (strcmp(stu[h].stu_ID,stu[i].stu_ID)==0) {printf("该学号已存在,请重新输⼊!\n");scanf("\n%s %s %s %s %s %s %s",&stu[i].stu_ID,&stu[i].stu_name,&stu[i].sex,&stu[i].age,&stu[i].collage,&stu[i].grade,&stu[i].contact);h = -1;}}//--fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%s\t%s\n",stu[i].stu_ID,stu[i].stu_name,stu[i].sex,stu[i].age,stu[i].collage,stu[i].grade,stu[i].contact);printf("\n录⼊成功,继续录⼊输⼊y,返回上⼀级请按任意键:");fflush(stdin);scanf("%c",&flag);fclose(fp);renew_stu();system("cls");stu_operate();}/*查询学⽣信息*/void search_stu(void){system("cls");printf("\n请选择查询⽅式:");printf("\n 1.学号查询");printf("\n 2.姓名查询");printf("\n请选择:");int h;scanf(" %d",&h);switch(h){case 1:search_stu_id();break;case 2:search_stu_name();break;}}/*学号查询*/void search_stu_id(void){system("cls");char id[9];printf("\n输⼊学⽣的学号:");fflush(stdin);scanf("%s",id);int h;for(h = 0;h <= i;h++){if(strcmp(stu[h].stu_ID,id)==0){system("cls");printf("查找成功!");printf("\n\n\t学号\t姓名\t性别\t年龄\t系别\t班级\t联系⽅式");printf("\n\t-----------------------------------------------------------------");printf("\n\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",stu[h].stu_ID,stu[h].stu_name,stu[h].sex,stu[h].age,stu[h].collage,stu[h].grade,stu[h].contact); system("pause");system("cls");stu_operate();}}system("cls");printf("没有此学号!\n");system("pause");system("cls");stu_operate();}/*姓名查询*/void search_stu_name(void){system("cls");char name[9];printf("\n输⼊学⽣的姓名:");fflush(stdin);scanf("%s",name);int h;for(h = 0;h <= i;h++){if(strcmp(stu[h].stu_name,name)==0){system("cls");printf("查找成功!");printf("\n\n\t学号\t姓名\t性别\t年龄\t系别\t班级\t联系⽅式");printf("\n\t---------------------------------------------------------");printf("\n\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",stu[h].stu_ID,stu[h].stu_name,stu[h].sex,stu[h].age,stu[h].collage,stu[h].grade,stu[h].contact); system("pause");system("cls");stu_operate();}}system("cls");printf("没有此姓名!");system("pause");system("cls");stu_operate();}/*显⽰所有学⽣信息*/void show_stu(void){int h;if(i == -1){printf("\n还没有录⼊信息!\n");system("pause");system("cls");stu_operate();}system("cls");printf("\n\n\t学号\t姓名\t性别\t年龄\t系别\t班级\t联系⽅式");printf("\n\t---------------------------------------------------------");//fflush(stdin);printf("\n\t1.修改");printf("\n\t2.删除");printf("\n\t3.返回");printf("\n\n 选择要进⾏的操作:");int flag;fflush(stdin);scanf("%d",&flag);switch(flag){case 1:edit_stu();break;case 2:delete_stu();break;default:system("cls");stu_operate();break;}}/*编辑学⽣信息*/void edit_stu(void){printf("\n输⼊需要编辑的学⽣的学号:");char id[10];getchar();scanf("%s",id);int h;for(h = 0;h <= i;h++){if(strcmp(stu[h].stu_ID,id)==0){//找到需要编辑的⾏system("cls");printf("\n\n\t学号\t姓名\t性别\t年龄\t系别\t班级\t联系⽅式");printf("\n\t---------------------------------------------------------");printf("\n\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",stu[h].stu_ID,stu[h].stu_name,stu[h].sex,stu[h].age,stu[h].collage,stu[h].grade,stu[h].contact); printf("\n这是修改前的数据,请依次输⼊修改值:\n\t");fflush(stdin);scanf("%s %s %s %s %s %s %s",&stu[h].stu_ID,&stu[h].stu_name,&stu[h].sex,&stu[h].age,&stu[h].collage,&stu[h].grade,&stu[h].contact); int k;for(k = 0;k <= i;k++){if(strcmp(stu[k].stu_ID,stu[h].stu_ID)==0){if(k==h){continue;} else {//学号不唯⼀printf("\n此学号已存在!重新输⼊学号:");fflush(stdin);scanf("%s",&stu[h].stu_ID);k = -1;}}}/*将修改信息写⼊⽂件*///思想:将原⽂件重新写⼊⼀遍renew_stu();system("cls");printf("修改成功!\n");system("pause");system("cls");stu_operate();}}printf("\n此学号不存在!\n");system("pause");system("cls");stu_operate();}/*删除学⽣信息*/void delete_stu(void){printf("\n输⼊需要编辑的学⽣的学号:");char id[10];getchar();scanf("%s",id);int h;for(h = 0;h <= i;h++){if(strcmp(stu[h].stu_ID,id)==0){//找到需要编辑的⾏system("cls");//检查他/她是否选课了int a;for(a = 0;a <= x;a++){if(h==sel[a].s){//选课了则将对应课程记录减1,以及选课数组减1delete_sel(a);a = -1;x--;continue;}}renew_stu();printf("修改成功!\n");system("pause");system("cls");stu_operate();}int k;for(k = h+1;k <= i;k++,h++){//将数组直接向前移动strcpy(stu[h].stu_ID,stu[k].stu_ID);strcpy(stu[h].stu_name,stu[k].stu_name);strcpy(stu[h].sex,stu[k].sex);strcpy(stu[h].grade,stu[k].grade);strcpy(stu[h].contact,stu[k].contact);strcpy(stu[h].collage,stu[k].collage);strcpy(stu[h].age,stu[k].age);}/*将修改信息写⼊⽂件*///思想:将原⽂件重新写⼊⼀遍renew_stu();i--;system("cls");printf("修改成功!\n");system("pause");system("cls");stu_operate();}}printf("\n此学号不存在!\n");system("pause");system("cls");stu_operate();}//--------------------------------------课程信息插⼊--------------------------------------void input_cou(void){char flag;FILE * fp;//--判断⽂件是否为空fp = fopen("course.txt","r+");flag = fgetc(fp);if(flag==EOF){fprintf(fp,"代码\t名称\t性质\t总学时\t学分\t开课学期\t选修⼈数\n");}fclose(fp);//--fp = fopen("course.txt","a+");if(fp == NULL){printf("打开⽂件失败!");system("cls");cou_operate();}printf("代码\t名称\t性质\t总学时\t学分\t开课学期\n");while(1){j++;scanf("%s %s %s %s %s %s",&cou[j].course_ID,&cou[j].course_name,&cou[j].property,&cou[j].period,&cou[j].credit,&cou[j].time);//--数据查重int h;for(h = 0;h < j;h++){if(j == 0) break;//第⼀条数据不需要查重if (strcmp(cou[h].course_ID,cou[j].course_ID)==0) {printf("该课程号已存在,请重新输⼊!\n");scanf("\n%s %s %s %s %s %s",&cou[j].course_ID,&cou[j].course_name,&cou[j].property,&cou[j].period,&cou[j].credit,&cou[j].time);h = -1;}}//--fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%s\t\t%d\n",cou[j].course_ID,cou[j].course_name,cou[j].property,cou[j].period,cou[j].credit,cou[j].time,cou[j].people); printf("\n录⼊成功,继续录⼊输⼊y,返回上⼀级请按任意键:");fflush(stdin);scanf("%c",&flag);fclose(fp);if(flag!='y'&&'Y') break;fp = fopen("course.txt","a");}renew_cou();system("cls");cou_operate();}/*查询课程信息*/void search_cou(void){system("cls");printf("\n请选择查询⽅式:");printf("\n 1.课程号查询");printf("\n 2.课程名查询");printf("\n请选择:");int h;scanf(" %d",&h);case 2:search_cou_name();break;}}/*课程号查询*/void search_cou_id(void){system("cls");char id[9];printf("\n输⼊课程号:");fflush(stdin);scanf("%s",id);int h;for(h = 0;h <= j;h++){if(strcmp(cou[h].course_ID,id)==0){system("cls");printf("查找成功!");printf("\n\n\t代码\t名称\t性质\t总学时\t学分\t开课学期\t选修⼈数");printf("\n\t-----------------------------------------------------------------");printf("\n\t%s\t%s\t%s\t%s\t%s\t%s\t\t%d\n",cou[h].course_ID,cou[h].course_name,cou[h].property,cou[h].period,cou[h].credit,cou[h].time,cou[h].people); system("pause");system("cls");cou_operate();}}system("cls");printf("没有此课程号!\n");system("pause");system("cls");cou_operate();}/*课程名查询*/void search_cou_name(void){system("cls");char name[9];printf("\n输⼊课程名:");fflush(stdin);scanf("%s",name);int h;for(h = 0;h <= j;h++){if(strcmp(cou[h].course_name,name)==0){system("cls");printf("查找成功!");printf("\n\n\t代码\t名称\t性质\t总学时\t学分\t开课学期\t选修⼈数");printf("\n\t---------------------------------------------------------");printf("\n\t%s\t%s\t%s\t%s\t%s\t%s\t\t%d\n",cou[h].course_ID,cou[h].course_name,cou[h].property,cou[h].period,cou[h].credit,cou[h].time,cou[h].people); system("pause");system("cls");cou_operate();}}system("cls");printf("没有此课程名!");system("pause");system("cls");cou_operate();}/*显⽰所有课程信息*/void show_cou(void){int h;if(j == -1){printf("\n还没有录⼊信息!\n");system("pause");system("cls");cou_operate();}system("cls");printf("\n\n\t代码\t名称\t性质\t总学时\t学分\t开课学期\t选修⼈数");printf("\n\t-------------------------------------------------------------");for(h = 0;h <= j;h++){printf("\n\t%s\t%s\t%s\t%s\t%s\t%s\t\t%d\n",cou[h].course_ID,cou[h].course_name,cou[h].property,cou[h].period,cou[h].credit,cou[h].time,cou[h].people); }//fflush(stdin);printf("\n\t1.修改");printf("\n\t2.删除");printf("\n\t3.返回");printf("\n\n 选择要进⾏的操作:");int flag;fflush(stdin);scanf("%d",&flag);switch(flag){case 1:edit_cou();break;system("cls");cou_operate();break;}}/*编辑课程信息*/void edit_cou(void){printf("\n输⼊需要编辑的课程号:");char id[10];getchar();scanf("%s",id);int h;for(h = 0;h <= j;h++){if(strcmp(cou[h].course_ID,id)==0){//找到需要编辑的⾏system("cls");printf("\n\n\t代码\t名称\t性质\t总学时\t学分\t开课学期");printf("\n\t-------------------------------------------------------------");printf("\n\t%s\t%s\t%s\t%s\t%s\t%s\n",cou[h].course_ID,cou[h].course_name,cou[h].property,cou[h].period,cou[h].credit,cou[h].time); printf("\n这是修改前的数据,请依次输⼊修改值:\n\t");fflush(stdin);scanf("%s %s %s %s %s %s",&cou[h].course_ID,&cou[h].course_name,&cou[h].property,&cou[h].period,&cou[h].credit,&cou[h].time); int k;for(k = 0;k <= j;k++){if(strcmp(cou[k].course_ID,cou[h].course_ID)==0){if(k==h){continue;} else {//课程号不唯⼀printf("\n此课程号已存在,重新输⼊:");fflush(stdin);scanf("%s",&cou[h].course_ID);k = -1;}}}/*将修改信息写⼊⽂件*///思想:将原⽂件重新写⼊⼀遍renew_cou();system("cls");printf("修改成功!\n");system("pause");system("cls");cou_operate();}}printf("\n此课程号不存在!\n");system("pause");system("cls");cou_operate();}/*删除课程信息*/void delete_cou(void){printf("\n输⼊需要编辑的课程号:");char id[10];getchar();scanf("%s",id);int h;for(h = 0;h <= j;h++){if(strcmp(cou[h].course_ID,id)==0){//找到需要编辑的⾏system("cls");//如果只有⼀条记录if(j==0){j = -1;renew_cou();printf("修改成功!\n");system("pause");system("cls");cou_operate();}//查看是否有⼈选课if(cou[h].people!=0){//有⼈选课时int a;for(a = 0;a <= x;a++){if(sel[a].c == h){delete_sel(a);a = -1;x--;continue;}}}int k;for(k = h+1;k <= j;k++,h++){//将数组直接向前移动strcpy(cou[h].course_ID,cou[k].course_ID);strcpy(cou[h].course_name,cou[k].course_name);strcpy(cou[h].property,cou[k].property);}/*将修改信息写⼊⽂件*///思想:将原⽂件重新写⼊⼀遍renew_cou();j--;system("cls");printf("修改成功!\n");system("pause");system("cls");cou_operate();}}printf("\n此课程号不存在!\n");system("pause");system("cls");cou_operate();}//--功能函数/*更新系统数据⾄⽂件*/void renew_stu(void){FILE * fp;fp = fopen("student.txt","w+");if(fp == NULL){printf("\n打开⽂件失败,⽆法保存⾄⽂件。

C语言选修课系统

C语言选修课系统
case '2':score_search();break;
case '3':character_search();break;
}
}
}
voidscore_search()
{
int i,n,a=0;
system("cls");
printf("\n请输入想要查询的学分:");
scanf("%d",&n);
for(i=0;i<id;i++)
if(n==lesson[i].score)
{
system("cls");
printf("编号:%d\n",lesson[i].Num);
printf("课程:%s\n",lesson[i].Name);
printf("课程性质:%s\n",lesson[i].Character);
C语言程序设计报告
09114104
学生选修课程系统设计
高扬
2009-12-28
C语言课程设计实验报告
1.设计目的:
假设有n门课程,每门课程有课程编号,课程名称,课程性质,总学时,授课学时,实验或上机学时,学分,开课学期等信息,学生可按要求(如总学分不得少于60)自由选课。试设计一选修课程系统,使之能提供以下功能:
}lesson[10];
voidmenu_select()
{
system("cls");
printf("**************Menu***************\n");

c语言程序设计之学生选修课系统设计代码

c语言程序设计之学生选修课系统设计代码

c语言程序设计之学生选修课系统设计代码在学生选修课系统设计中,C语言程序设计是必不可少的一部分。

本文将详细介绍学生选修课系统的设计代码,包括学生信息管理、课程信息管理、选课与退课等功能。

一、学生信息管理在学生选修课系统中,首先需要实现学生信息的管理功能。

以下是学生信息管理的代码示例:#include <stdio.h>#include <stdlib.h>#include <string.h>struct Student {char id[20];char name[20];int age;};void addStudent(struct Student students[], int *count) {printf("请输入学号:");scanf("%s", students[*count].id);printf("请输入姓名:");scanf("%s", students[*count].name);printf("请输入年龄:");scanf("%d", &students[*count].age);(*count)++;printf("添加学生信息成功!\n");}void deleteStudent(struct Student students[], int *count) { char id[20];printf("请输入要删除的学生学号:");scanf("%s", id);for (int i = 0; i < *count; i++) {if (strcmp(students[i].id, id) == 0) {for (int j = i; j < *count - 1; j++) {strcpy(students[j].id, students[j+1].id);strcpy(students[j].name, students[j+1].name); students[j].age = students[j+1].age;}(*count)--;printf("删除学生信息成功!\n");return;}}printf("未找到对应学生信息!\n");}void displayStudents(struct Student students[], int count) {printf("学号\t姓名\t年龄\n");for (int i = 0; i < count; i++) {printf("%s\t%s\t%d\n", students[i].id, students[i].name, students[i].age);}}二、课程信息管理除了学生信息管理外,还需要实现课程信息的管理功能。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

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> 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,&ttim e,&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填补。

相关文档
最新文档