C语言程序设计报告学生选修课系统
- 格式:doc
- 大小:28.63 KB
- 文档页数:11
c语言学生选课系统设计详细设计详细设计:1. 数据结构设计:- 学生信息结构体:包含学生姓名、学号、已选课程等信息。
- 课程信息结构体:包含课程名称、课程编号、授课教师等信息。
- 教师信息结构体:包含教师姓名、教师编号等信息。
2. 功能设计:- 学生选课功能:学生可以浏览可选课程列表,并选择自己感兴趣的课程进行选修。
选修成功后,将该门课程加入学生的已选课程列表中。
- 课程管理功能:教师可以添加、修改和删除课程信息。
- 学生信息管理功能:教师可以查看学生的选课情况,并进行相关操作,如修改学生选课等。
3. 界面设计:- 学生选课界面:显示可选课程列表,并提供选课按钮。
- 课程管理界面:显示课程信息列表,并提供添加、修改和删除按钮。
- 学生信息管理界面:显示学生信息列表和选课情况,并提供相关操作按钮。
4. 数据库设计:- 学生表:包含学生姓名、学号、已选课程等字段。
- 课程表:包含课程名称、课程编号、授课教师等字段。
- 教师表:包含教师姓名、教师编号等字段。
5. 系统流程设计:- 学生选课流程:学生登录系统后,进入选课界面,浏览可选课程列表,选择自己感兴趣的课程进行选修。
选修成功后,系统更新学生的已选课程列表。
- 课程管理流程:教师登录系统后,进入课程管理界面,可以进行添加、修改和删除课程信息的操作。
系统更新课程表。
- 学生信息管理流程:教师登录系统后,进入学生信息管理界面,可以查看学生的选课情况,并进行相关操作,如修改学生选课。
系统更新学生表。
6. 错误处理设计:- 输入错误处理:对于用户输入的非法数据,系统进行提示并要求重新输入。
- 数据库错误处理:对于数据库操作过程中的错误,系统进行捕获并给出相应的错误提示。
以上为一个简单的C语言学生选课系统的详细设计。
根据具体需求,还可以进行更加详细和具体的设计。
课程设计题目:选课管理系统《1》选课管理系统要求:•学生选课信息的添加(学生选课信息包括学生学号、课程名称、学分)•学生选课信息的删除•学生选课信息查询(查询每个学生的选课信息,每个学生选课的总学分,选具体某门课程(课程名输入)的学生名单))•《2》实现思路个人信息用结构体定义,解决的方案可以用结构体数组,或是链表作为临时数据处理,用文件来存储数据。
注意数据定义的数据类型,用函数实现相应的功能,然后在主程序中调用,程序运行的时候用菜单选择功能,然后进行相关操作。
1---------选课信息的添加------------2---------选课信息的删除------------3---------选课信息的修改------------4---------选课信息的查询------------5---------从文件读入学生信息--------------6---------------删除文件中学生信息-------------7---------------保存学生信息--------------------8----------------退出------------------------------《3》实验总结(分析程序的得与失)这个课题是设计一个成绩管理系统,该系统能够较好的管理好学生的成绩,也拥有比较完善的功能。
在编写过程中,我逐步的了解了程序模块化设计的思想含义。
在整个程序设计的过程中语法的错误还是比较容易检查的,但是对于那些逻辑思维的问题方面的缺陷不易查出,因此常常出现系统提示没有错误但是仍然不能够正常运行的境况,尽管有很多不足之处,但我在整个系统程序设计的过程中,我可以感受到自己对C语言有了一定的掌握,对整体的把握度也提高了很多。
《4》心得体会通过这周的编程我发现了自己的一些不足,在编写时经常犯一些低级错误,由于自己的马虎而浪费了不少时间。
在不知如何进行的时候有一种不自信,总想别人正在做什么,这些不足既然被发现就得在以后的做事中注意,争取改掉。
中南民族大学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语言大型作业实践报告计算机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);。
课程设计报告课程设计题目:学生选课管理系统学号: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语言学号 201210006qq 专业地质学所在院系地球科学学院教师姓名 ### 日期: 2014 年 12 月 27 日评语对课程报告的评语:总成绩:评阅人签名:目录一、实习感悟 (1)二、课程要求 (2)三、各个模块的流程图 (3)四、源程序 (8)五、调试结果 (18)六、程序有待改进的地方 (23)(一)实习感悟经过这次只有32个学时c语言实习,我学会了许多,c语言实习是一个枯燥乏味但有充满了乐趣的过程,你会为一个小小的错误而坐立不安;你会为一个下午的编程却错误连篇而痛心疾首;但也有稍微改动一个符号的错误,瞬间眼前几十个错误就灰飞烟灭的心灵舒畅。
这次实习让我加深了对C语言的了解,而不纯粹是课本中学到的那些理论,平时乏味的课程,通过自己动手亲自编写,变的生动有趣,而在自己动手的过程中,出现的问题很多,比理论要难的多,当一个程序写完以后,经常会有很多错误而没法解决。
我就曾因为进行浏览操作时,缺失一个读出文件的函数而苦恼不已,最后还是在助教帮助下找到这个运行时出现的错误。
我实习的内容是编一个学生选修课程系统。
看似简单的事情对于我来说是个多么大的挑战,一年之前学习过的c语言早就忘得差不多了,于是我只好重新回忆以前学过的c语言知识。
虽然我们在一年前c语言上课时曾经实习过,但那只不过是c语言的简单的函数的实习,是让我们更好的熟悉书本的每一个函数和各种符号的正确使用。
所以我们对c语言的理解仅仅停留在函数阶段,而我们这次实习却是各种函数的使用,很多时候都是和文件的使用结合在一起,而恰恰我对文件的使用不太熟悉,只好硬着头皮看了文件这个模块一个下午,对文件的输入与输出有了基本的了解。
32个学时的实习其实只有8大节课,时间十分的短。
老师并没有给我们太多的解析,也容不得我们自己用太多的时间去考虑,只是给了我们一个书本的模块,让我们按照其方式去编一个程序。
这次的实习虽然并没有让我成为一位编程序的高手,但却让我掌握了许多。
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++课程设计--学生选课系统程序设计报告计算机科学与技术学院学生选课系统程序设计报告班级: 1003专业:嵌入式软件指导教师:吴克立杨素娣学号: 211011016姓名:李倩倩2010年2月29日目录一.设计目的.....................................二.总体设计.....................................三.详细设计.....................................1.界面设计...................................2.课程信息设计............................3.学生信息设计............................4.选课设计...................................四.测试与调试.................................五.心得体会....................................一.设计目的网上选课系统是针对在校学生和教师使用,从学生的角度来说,由于学校教学制度的改革,现在大部分高等院校开始实行的是学生的自主选课模式,传统的教学模式(学生按照学校安排好的课程上课)已经不能适应新型的教学手段,如果仍然通过纸上的方式选课,一方面浪费的大量的人力、物力资源,另一方面浪费时间以及在人为的统计过程中不可避免出现的差错等情况。
随着学校规模的不断扩大,专业、班级、学生的数量急剧增加,有关学生选课的各种信息量也成倍增长,而目前许多高校的学生选课管理仍停留在复杂的人工操作上,重复工作较多,工作量大,效率低,这种弊端会越来越多的暴露出来。
因此,利用网络,使学生只要在计算机前输入自己的个人选课信息即可完成原来几倍的作业量。
从教师的角度来说,同样是节省了大量的工作量,由于教师提出代课申请完成课程发布的工作较学生选课而言更加的复杂,因此通过网上进行课程发布能大幅度的减少教师的工作量,减少错误的发生几率。
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填补。
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;牰湩晴尨输入要插入的课程信息:\n);scanf(%d%s%s%d%d%d%d%d,&subj->num,subj->name,subj->kind,&subj->stime,&subj->ttime,&su bj->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;}}牰湩晴尨继续插入请按回车,结束请按空格:\n);ch1=getchar(); //将回车键赋给CH1,否则subj->term输完后输入的回车键会赋给CH,因此用CH1填补。
ch=getchar();}return head;}SUB *del(SUB *head){SUB *p1,*p2;char ch='a',ch1;int num;while(ch!=' '){牰湩晴尨输入想要删除的课程编号:\n);scanf(%d,&num);if(head->num==num){p2=head;head=head->next;free(p2);}if(head==NULL)return NULL;p1=head;p2=head->next;while(p2){if(p2->num==num){p1->next=p2->next;free(p2);}else p1=p2;p2=p1->next;}牰湩晴尨继续删除请按回车,结束请按空格:\n);ch1=getchar(); //将回车键赋给CH1,否则num输完后再输入的回车键会赋给CH,因此用CH1填补。