#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct COURSE
{
char number[20];//课程编号
char name[20];//课程名
char style[20];//课程类型
int time[2];//授课学时,上机学时
int score;//学分
int n;//开课学期
}course[100];
int N=0;
void Input_Course()
{
system("cls");
printf("请输入输入课程编号\n");
scanf("%s",&course[N].number);
printf("请输入输入课程名\n");
scanf("%s",&course[N].name);
printf("请输入输入课程类型\n");
scanf("%s",&course[N].style);
printf("请输入输入课程授课学时\n");
scanf("%d",&course[N].time[0]);
printf("请输入输入课程实验或上机学时\n");
scanf("%d",&course[N].time[1]);
printf("请输入输入课程学分\n");
scanf("%d",&course[N].score);
printf("请输入输入课程开课学期\n");
scanf("%d",&course[N].n);
N++;
printf("新增课程成功!\n");
system("pause");
}
int Menu()
{
int n;
system("cls");
printf("1:课程信息录入\n");
printf("2:课程信息浏览\n");
printf("3:按总学时排序\n");
printf("4:按学时查询\n");
printf("0:退出\n");
printf("请选择编号:");
scanf("%d",&n);
while(n<0||n>4)
{
printf("输入错误,请重新输入!\n");
scanf("%d",&n);
}
return n;
}
void Show_Iofo()
{
int i;
system("cls");
if(0==N)
{
printf("无课程信息!\n");
}
else
{
printf("%-10s%-20s%-10s%-10s%-16s%-10s%-4s\n","编号","课程名","类型","授课学时","上机或实验学时","学分","学期");
for(i=0;i<N;i++)
{
printf("%-10s%-20s%-10s%-10d%-16d%-10d%-4d\n",course[i].number,course[i].name,course[i].style,course[i].time[0],course[i].time[1],course[i].score,course[i].n);
}
}
system("pause");
}
void Sort_SUM()
{
struct COURSE temp;
int i,j;
for(i=0;i<N;i++)
{
for(j=i+1;j<N;j++)
{
if( course[i].time[0]+course[i].time[1]<course[j].time[0]+course[j].time[1] )
{
temp=course[j];
course[j]=course[i];
course[i]=temp;
}
}
}
}
void Serach_Sum_Time()
{
int i;
int temp;
system("cls");
printf("请输入要查询的总学时:\n");
scanf("%d",&temp);
printf("%-10s%-20s%-10s%-10s%-16s%-10s%-4s\n","编号","课程名","类型","授课学时","上机或实验学时","学分","学期");
for(i=0;i<N;i++)
{
if(temp==course[i].time[0]+course[i].time[1])
{
printf("%-10s%-20s%-10s%-10d%-16d%-10d%-4d\n",course[i].number,course[i].name,course[i].style,course[i].time[0],course[i].time[1],course[i].score,course[i].n);
}
}
system("pause");
}
void Serach_Teach_Time()
{
int i;
int temp;
system("cls");
printf("请输入要查询的授课学时:\n");
scanf("%d",&temp);
printf("%-10s%-20s%-10s%-10s%-16s%-10s%-4s\n","编号","课程名","类型","授课学时","上机或实验学时","学分","学期");
for(i=0;i<N;i++)
{
if(temp==course[i].time[0])
{
printf("%-10s%-20s%-10s%-10d%-16d%-10d%-4d\n",course[i].number,course[i].name,course[i].style,course[i].time[0],course[i].time[1],course[i].score,course[i].n);
}
}
system("pause");
}
void Serach_Test_Time()
{
int i;
int temp;
system("cls");
printf("请输入要查询的上机或实验学时:\n");
scanf("%d",&temp);
printf("%-10s%-20s%-10s%-10s%-16s%-10s%-4s\n","编号","课程名","类型","授课学时","上机或实验学时","学分","学期");
for(i=0;i<N;i++)
{
if(temp==course[i].time[1])
{
printf("%-10s%-20s%-10s%-10d%-16d%-10d%-4d\n",course[i].number,course[i].name,course[i].style,course[i].time[0],course[i].time[1],course[i].score,course[i].n);
}
}
system("pause");
}
void Serach_Menu()
{
int n;
do
{
system("cls");
printf("1:按授课学时查询\n");
printf("2:按上机或实验学时查询\n");
printf("3:按总学时查询\n");
printf("0:退出\n");
scanf("%d",&n);
while(n<0||n>3)
{
printf("输入范围错误,查询输入\n");
scanf("%d",&n);
}
switch(n)
{
case 1:
Serach_Teach_Time();
break;
case 2:
Serach_Test_Time();
break;
case 3:
Serach_Sum_Time();
break;
}
}while(n!=0);
}
int main()
{
int n;
do
{
n=Menu();
switch(n)
{
case 1:
Input_Course();
break;
case 2:
Show_Iofo();
break;
case 3:
Sort_SUM();
Show_Iofo();
break;
case 4:
Serach_Menu();
break;
}
}while(n!=0);
return 0;
}
课时管理系统
最新推荐文章于 2024-05-04 22:17:32 发布