当前位置:网站首页>C language course set up student elective course system (big homework)
C language course set up student elective course system (big homework)
2022-07-01 06:26:00 【Ordinary senior】

One 、 Design function ( The article is for reference only )
(1) The system works as a menu ;
(2) Input function of course information and student information ( Course information is saved in files )---- Input ;
(3) Course information browsing function ---- Output ;
(4) Query function ( At least one query method )— Algorithm ;
(5) Query by credit ;
(6) Students' electives of a certain course ( optional ).
Two 、 Function display




3、 ... and 、 Mind mapping



Four 、 Program source code
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int N1,N2;
int n=0;
struct course
{
int num1; // Course number
char name1[20];
char major[20];
char type[20];
int credit;
int period;
char teacher[20];
int people; // The number of people taking this course
struct course *next; }; // Structure pointer
struct student
{
int num2;
char name2[20];
int nelenum[50]; // Selected course number
int nelen; // Credits of selected courses and
struct student * next;};
struct course * head1;
struct student * head2;
void zhang() // Enter course information from the keyboard
{
struct course *p1,*p2;
N1=0;
p1=p2=(struct course *)malloc(sizeof(struct course));
int y,n;
if(n==0)
do
{
printf("--------------------\n");
printf(" Please enter the course number :");
scanf("%d",&p1->num1);
printf(" Please enter the course name :");
scanf("%s",p1->name1);
printf(" Please enter your major :");
scanf("%s",p1->major);
printf(" Please enter the nature of the course :");
scanf("%s",p1->type);
printf(" Please enter credits :");
scanf("%d",&p1->credit);
printf(" Please enter the class hour :");
scanf("%d",&p1->period);
printf(" Please enter the name of the teacher :");
scanf("%s",p1->teacher);
n++;
p1++;
printf("\n1. Continue to input .\n0. Input complete .\n");
printf(" Please select :");
scanf("%d",&y);
}
while(y==1);
printf(" Tips : Input complete ! You have entered a total of %d individual \n",n);
}
void zhang1() // Enter the course information from the file
{
FILE * fp;
char filepath[20];
struct course *p1,*p2;
N1=0;
printf(" Please enter the path you want to read :");
getchar();
gets(filepath);
if((fp=fopen(filepath,"r"))==NULL)
{
printf(" Can't find %s file !\n",filepath);
exit(0);
}
p1=p2=(struct course*)malloc(sizeof(struct course));
fscanf(fp,"%d%s%s%s%d%d%s%d",&p1->num1,p1->name1,p1->major,p1->type,&p1->credit,&p1->period,p1->teacher,&p1->people);
while(!feof(fp))
{
N1=N1+1;
if(N1==1)
head1=p1;
else
p2->next=p1;
p2=p1;
p1=(struct course * )malloc(sizeof(struct course));
fscanf(fp,"%d%s%s%s%d%d%s%d",&p1->num1,p1->name1,p1->major,p1->type,&p1->credit,&p1->period,p1->teacher,&p1->people);
}
p2->next=NULL;
}
void load() // Enter the course information function
{
int i;
printf("\t\t\t Enter course information \n");
printf("\n1. Enter... From the keyboard ");
printf("\n2. Enter... From the file ");
printf("\n3. Back to main menu \n");
printf(" Please select 1-3:");
scanf("%d",&i);
switch(i)
{
case 1:zhang();break;
case 2:zhang1();break;
case 3:break; }
}
void insert(struct course *incourse) // Add course information
{
struct course *p0,*p1,*p2;
p1=head1;
p0=incourse;
if(head1==NULL)
{
head1=p0;
p0->next=NULL;
}
else
{
while((p0->num1>p1->num1) && (p1->next!=NULL))
{
p2=p1;
p1=p1->next;
}
if(p0->num1<=p1->num1)
{
if(head1==p1)
head1=p0;
else
p2->next=p0;
p0->next=p1;
}
else
{
p1->next=p0;
p0->next=NULL;
}
}
N1=N1+1;
}
void delc(int num1) // Delete course information
{
struct course *p1,*p2;
if(head1==NULL)
{
printf("\n Cannot delete !\n");
goto end;
}
p1=head1;
while(num1!=p1->num1 && p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(num1==p1->num1)
{
if(p1==head1)
head1=p1->next;
else
p2->next=p1->next;
printf(" deleted \n");
N1=N1-1;
}
else
printf(" There is no such course \n");
end:;
}
void managementc() // Course information management function
{
struct course * p1;
int i,num1;
printf("\t\t\t Course information management \n");
printf("1. Add courses \n");
printf("2. Delete course \n");
printf("3. return \n");
printf(" Please enter 1-3:\n");
scanf("%d",&i);
switch(i)
{
case 1:{
struct course *p1,*p2;
N1=0;
p1=p2=(struct course *)malloc(sizeof(struct course));
int y,n;
if(n==0)
do
{
printf("--------------------\n");
printf(" Please enter the course number :");
scanf("%d",&p1->num1);
printf(" Please enter the course name :");
scanf("%s",p1->name1);
printf(" Please enter your major :");
scanf("%s",p1->major);
printf(" Please enter the nature of the course :");
scanf("%s",p1->type);
printf(" Please enter credits :");
scanf("%d",&p1->credit);
printf(" Please enter the class hour :");
scanf("%d",&p1->period);
printf(" Please enter the name of the teacher :");
scanf("%s",p1->teacher);
n++;
p1++;
printf("\n1. Continue to input .\n0. Input complete .\n");
printf(" Please select :");
scanf("%d",&y);
}
while(y==1);
printf(" Tips : Input complete ! You have entered a total of %d individual \n",n);
} break;
case 2:printf(" Please enter the course number you want to delete :\n");
scanf("%d",&num1);
delc(num1);break;
case 3:break;
}
}
void putin(void) // Input student information from the keyboard
{
int i,n,y;
struct student *p1,*p2;
N2=0;
p1=p2=(struct student *)malloc(sizeof(struct student));
do
{
printf(" Student number :\t");
scanf("%d",&p1->num2);
printf(" full name :\t");
scanf("%s",p1->name2);
p1->nelen=0;
for(i=0;i<20;i++) p1->nelenum[i]=0;
head2=NULL;
n++;
p1++;
printf("\n1. Continue to input .\n0. Input complete .\n");
printf(" Please select :");
scanf("%d",&y);
}
while(y==1);
printf(" Tips : Input complete ! You have entered a total of %d individual \n",n);
}
void putin2() // Enter student information from the file
{
int i=0;
FILE * fp;
char filepath[20];
struct student *p1,*p2;
N2=0;
printf(" Please enter the path you want to read :");
getchar();
gets(filepath);
if((fp=fopen(filepath,"rt"))==NULL)
{
printf(" Can't find %s file !\n",filepath);
exit(0);
}
p1=p2=(struct student*)malloc(sizeof(struct student));
fread(p1,sizeof(struct student),1,fp);
head2=NULL;
while(!feof(fp))
{
i=0;
N2=N2+1;
if(N2==1)
head2=p1;
else
p2->next=p1;
p2=p1;
p1=(struct student * )malloc(sizeof(struct student));
fread(p1,sizeof(struct student),1,fp);
}
p2->next=NULL;
}
void input() // Enter student information function
{
int i;
printf("\t\t\t Enter student information \n");
printf("\n1. Enter... From the keyboard \n");
printf("2. Enter... From the file \n");
printf("3. Back to main menu \n");
printf(" Please enter 1-3:\n");
scanf("%d",&i);
switch(i)
{
case 1:putin();break;
case 2:putin2();break;
case 3:break;
}
}
void inserts(struct student * incouse) // Add student information
{
struct student *p0,*p1,*p2;
p1=head2;
p0=incouse;
if(head2==NULL)
{
head2=p0;
p0->next=NULL;
}
else
{
while((p0->num2>p1->num2) && (p1->next!=NULL))
{
p2=p1;
p1=p1->next;
}
if(p0->num2 <= p1->num2)
{
if(head2==p1) head2=p0;
else p2->next=p0;
p0->next=p1;
}
else
{
p1->next=p0;
p0->next=NULL;}
}
N2=N2+1;
}
void dels(int num2) // Delete student information
{
struct student *p1,*p2;
if(head2==NULL)
{
printf("\n Cannot delete \n");
goto end;
}
p1=head2;
while(num2!=p1->num2 && p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(num2==p1->num2)
{
if(p1==head2)
head2=p1->next;
else
p2->next=p1->next;
printf(" deleted \n");
N2=N2-1;
}
else
printf(" There is no such student number \n");
end:;
}
void managements() // Student information management function
{
struct student * p1;
int i,num2;
printf("\t\t\t Student information management \n");
printf("1. Add student information \n");
printf("2. Delete student information \n");
printf("3. Back to main menu \n");
printf(" Please select 1-3:\n");
scanf("%d",&i);
switch(i)
{
case 1:{
p1=(struct student *)malloc(sizeof(struct student));
p1->nelen=0;
p1->nelenum[0]=0;
printf("num\tname\n");
scanf("%d%s",&p1->num2,p1->name2);
inserts(p1);}break;
case 2:{
printf(" Please enter the student number you want to delete :\n");
scanf("%d",&num2);
dels(num2);} break;
case 3:break;
}
}
void elect() // Students' course selection
{
struct student * s;
struct course * p1;
int a,i,b;
printf(" Please enter your student number :\n");
scanf("%d",&a);
s=head2;
while((s->num2)!=a&&s->next!=NULL) s=s->next;
if(s->num2!=a)
{
printf(" Your information does not exist , Please re-enter :\n");
goto end;
}
if((s->nelen)>10)
{
printf(" Your credits are full ");
goto end;
}
printf(" Please enter the course number you want to take \n");
scanf("%d",&b);
for(i=0;(s->nelenum[i])==0;i++);
s->nelenum[i]=b;
p1=head1;
while((p1->num1)!=b)
p1=p1->next;
for(i=0;(s->nelenum[i])!=0;i++);
s->nelenum[i]=b;
(p1->people)++;
(s->nelen)=(s->nelen)+(p1->credit);
(p1->people)++;
end:;
}
void back() // Student withdrawal
{
struct student * p;
struct course * p1;
int b,i,j,a;
printf(" Please enter your student number :\n");
scanf("%d",&a);
p=head2;
while(p->num2!=a&&p!=NULL) p=p->next;
if(p==NULL)
printf(" Your information does not exist :\n");
else
{
printf(" Please enter the course you want to withdraw :\n");
scanf("%d",&b);
p1=head1;
while(p1->num1!=b) p1=p1->next;
for(i=0;p->nelenum[i]!=b;i++);
for(j=i;p->nelenum[j]!=0;j++)
p->nelenum[j]=p->nelenum[j+1];
p->nelenum[--j]=0;
(p->nelen)=(p->nelen)-(p1->credit);
(p1->people)--;
printf("succeed!\n");
}
}
void elective() // Student course selection information management
{
int i;
printf("\t\t\t Student course selection information management \n");
printf("1. Course selection \n");
printf("2. The drop \n");
printf("3. Back to main menu \n");
printf(" Please enter 1-3:\n");
scanf("%d",&i);
switch(i)
{
case 1:elect();break;
case 2:back();break;
case 3:break;
}
}
void listc() // Browse course information
{
struct course * p;
int i,j;
if(n!=0)
{
printf(" Total number of students :%d\n", n);
printf(" Course number Course name Major Course nature credits Class hour Teachers' The number of students who choose courses \n");
printf("-----------------------------------------------------\n");
for(i=0;i<n;i++)
printf("%6d%13s%13s%10s%7d%7d%12s%5d\n",&p->num1,p->name1,p->major,p->type,&p->credit,&p->period,p->teacher,&p->people);
}
else printf(" Tips : No data , Please input data !");
}
void lists() // Browse student information
{
struct student * p;
int a;
p=head2;
printf(" Student number The student's name Selected course number Credits of selected courses \n");
while(p!=NULL)
{
printf("%6d%13s",&p->num2,p->name2);
printf("%6d",&p->nelen);
for(a=0;p->nelenum[a]!=0&&a<14;a++)
printf("%d",&p->nelenum[a]);
printf("\n");
p=p->next;
}
}
void intoc() // Store course information
{
FILE * fp;
struct course * p;
char filepath[30];
printf(" Input path :");
getchar();
gets(filepath);
if((fp=fopen(filepath,"w"))==NULL)
{
printf("\ Can't store !");
exit(0);
}
p=head1;
while(p!=NULL)
{
fprintf(fp,"%d%s%s%s%d%d%s%d\n",p->num1,p->name1,p->major,p->type,p->credit,p->period,p->teacher,p->people);
p=p->next;
}
fclose(fp);
printf(" Stored %s file !\n",filepath);
}
void intos() // Store student information
{
FILE * fp;
struct student * p;
char filepath[30];
printf(" Please enter the path :");
getchar();
gets(filepath);
if((fp=fopen(filepath,"wt"))==NULL)
{
printf("\n Can't store !");
exit(0);
}
p=head2;
while(p!=NULL)
{
fwrite(p,sizeof(struct student),1,fp);
p=p->next;
}
fclose(fp);
printf(" Stored %s file !\n",filepath);
}
void into() // Information storage function
{
int i;
printf("\t\t\t Information storage \n");
printf("1. Course information storage \n");
printf("2. Student information storage \n");
printf("3. Back to main menu \n");
printf(" Please enter 1-3\n");
scanf("%d",&i);
switch(i)
{
case(1):intoc();break;
case(2):intos();break;
case(3):break;
}
}
void store() // Information storage browse function
{
int i;
printf("\t\t Information storage and browsing \n");
printf("1. Course information browsing \n");
printf("2. Student information browsing \n");
printf("3. Information storage \n");
printf("4. Back to main menu \n");
printf(" Please enter 1-4:\n");
scanf("%d",&i);
switch(i)
{
case(1):listc();break;
case(2):lists();break;
case(3):into();break;
case(4):break;
}
}
void search1() // Find student information by student number
{
int a,b;
struct student * p;
printf(" Please enter student number ");
scanf("%d",&a);
p=head2;
printf(" Student number The student's name Selected course number Credits of selected courses \n");
while(p!=NULL)
{
if(p->num2==a)
{
printf("%6d%13s ",p->num2,p->name2);
for(b=0;p->nelenum[b]!=0&&b<14;b++)
printf("%d",p->nelenum[b]);
printf("%10d\n",p->nelen);
}
p=p->next;
}
}
void search2() // Find student information by student name
{
int b;
char name[20];
struct student * p;
printf(" Please enter the name of the student you want to find :");
scanf("%s",name);
p=head2;
printf(" Student number The student's name Selected course number Credits of selected courses \n");
while(p!=NULL)
{
if(strcmp(name,p->name2)==0)
{
printf("%6d%13s ",p->num2,p->name2);
for(b=0;p->nelenum[b]!=0&&b<14;b++)
printf("%d",p->nelenum[b]);
printf("%10d\n",p->nelen);
}
p=p->next;
}
}
void search() // Student information search main function
{
int i;
printf("\t\t\t Student information search ");
printf("\n1. Search by student ID ");
printf("\n2. Search by name ");
printf("\n3. Back to main menu ");
printf("\n Please enter 1-3:");
scanf("%d",&i);
switch(i)
{
case 1:search1();break;
case 2:search2();break;
case 3:break;}}
int main() // The main function
{
char m;
int i;
start:
printf("\t\t\t*******************************\n");
printf("\n\t\t\t\t Student elective course system !\n");
printf("\n\t\t\t\t Welcome to this system !\n");
printf("\t\t\t*******************************\n");
printf("\n");
printf("\t\t\t\t----- Catalog -----\n");
printf("\t\t\t|1. Enter course information \n");
printf("\t\t\t|2. Course information management \n");
printf("\t\t\t|3. Enter student information \n");
printf("\t\t\t|4. Student information management \n");
printf("\t\t\t|5. Students' course selection \n");
printf("\t\t\t|6. Information storage and browsing \n");
printf("\t\t\t|7. Search for student information \n");
printf("\t\t\t|8. Exit the system \n");
printf(" Select the number in front of the function to enter the function :\n");
scanf("%d",&i);
switch(i)
{
case 1:system("cls");load(); goto start;break;
case 2:system("cls");managementc();goto start;break;
case 3:system("cls");input();goto start;break;
case 4:system("cls");managements();goto start;break;
case 5:system("cls");elective();goto start;break;
case 6:system("cls");store();goto start;break;
case 7:system("cls");search();goto start;break;
case 8:{
system("cls");
printf("Thank you for using this program!\n\nBye-Bye!\n");
}
}
return 0;
}

You can pay attention to it, and it will be updated continuously in the future 0.0( Thank you first )
边栏推荐
- Understanding of C manualresetevent class
- B-树系列
- C语言课设工资管理系统(大作业)
- [unity shader amplify shader editor (ASE) Chapter 9]
- Mongodb: I. what is mongodb? Advantages and disadvantages of mongodb
- Transformer le village de tiantou en un village de betteraves sucrières
- FPGA - clocking -02- clock wiring resources of internal structure of 7 Series FPGA
- 请求模块(requests)
- 高阶-二叉搜索树详解
- Differences between in and exists in MySQL
猜你喜欢

JMM详解

One of the characteristic agricultural products that make Tiantou village, Guankou Town, Xiamen into a "sweet" village is

【ManageEngine卓豪】网络运维管理是什么,网络运维平台有什么用

Excel visualization

【企业数据安全】升级备份策略 保障企业数据安全

虚幻 简单的屏幕雨滴后处理效果

C语言课设图书信息管理系统(大作业)

IT服务管理(ITSM)在高等教育领域的应用

FPGA - 7 Series FPGA internal structure clocking-01-clock Architecture Overview

Transformer le village de tiantou en un village de betteraves sucrières
随机推荐
交换机配置软件具有的作用
地宫取宝(记忆化深搜)
Uniapp tree level selector
Dongle data collection
How did ManageEngine Zhuohao achieve the goal of being selected into Gartner Magic Quadrant for four consecutive years?
Detailed steps for installing redis on Windows system
HDU - 1501 zipper (memory deep search)
浅谈SIEM
Tidb single machine simulation deployment production environment cluster (closed pit practice, personal test is effective)
【ManageEngine卓豪】移动终端管理解决方案,助力中州航空产业数字化转型
请求模块(requests)
SystemVerilog learning-07-class inheritance and package use
Freeswitch dial the extension number
[postgraduate entrance examination advanced mathematics Wu Zhongxiang +880 version for personal use] advanced mathematics Chapter II Basic Stage mind map
C语言课设学生选修课程系统(大作业)
【自动化运维】自动化运维平台有什么用
高阶-二叉平衡树
MongoDB:一、MongoDB是什么?MongoDB的优缺点
10 golang operator
Kubedm builds kubenetes cluster (Personal Learning version)