当前位置:首页 > 问答大全 > 急求C语言课程设计:学生成绩管理程序

急求C语言课程设计:学生成绩管理程序

被浏览: 0次 2023年08月15日 02:56
热门回答(5个)
游客1

#include
#include
#define LIST_INIT_SIZE 10
#define INCREAMENT 5
#define TRUE 1
#define FALSE 0
#define ERROR 0
#define OVERFLOW -2
#define OK 1
#define LT(a,b) ((a)<(b))
int i,j,low,high;
typedef int Status;
typedef struct
{int seat;
char name[7];
char sex[7];
int year;
int score[3];
int total;
float average;
}rec;
typedef struct
{rec *stu;
int length;
int listsize;
}SqList;
typedef struct
{int grade;
int lowest;
int highest;
double ave;
int nam;
}dis;
typedef struct
{dis *sco;
int len;
int size;
}Dis;
Status InitList_Sq(SqList *L)
{(*L).stu=(rec *)malloc(LIST_INIT_SIZE*sizeof(rec));
if(!(*L).stu) exit (OVERFLOW);
(*L).length=5;
(*L).listsize=10;
return OK;
}
Status List_Sq(Dis *S)
{(*S).sco=(dis *)malloc(LIST_INIT_SIZE*sizeof(dis));
if(!(*S).sco) exit (OVERFLOW);
(*S).len=3;
(*S).size=10;
return OK;
}
Status Insert(SqList *L)
{int g;
printf("\nHow many students you want to input:");
scanf("%d",&g);
for(i=(*L).length+1;i<=(*L).length+g;i++)
{if((*L).listsize<=(*L).length)
{(*L).stu=(int *)realloc((*L).stu,((*L).listsize+INCREAMENT)*sizeof(int));
if(!(*L).stu)exit(OVERFLOW);
(*L).listsize+=INCREAMENT;
}
printf("please input student'infmation:");
printf("\nxue hao:");
scanf("%d",&(*L).stu[i].seat);
printf("\nname:"仿大手);
scanf("%s",&(*L).stu[i].name);
printf("\仿告nsex:");
scanf("备嫌%s",&(*L).stu[i].sex);
printf("\nyear:");
scanf("%d",&(*L).stu[i].year);
printf("\ngrades of three disciplines:");
for(j=0;j<3;j++)
scanf("%d",&(*L).stu[i].score[j]);
}
(*L).length+=g;
}
Status Delete(SqList *L,int i)
{rec *p,*q;
rec *e;
if((i<1)||(i>(*L).length))return ERROR;
p=&((*L).stu[i]);
*e=*p;
q=(*L).stu+(*L).length;
for(++p;p<=q;++p)*(p-1)=*p;
--(*L).length;
return OK;
}
Computing(SqList *L)
{for(i=0;i<=(*L).length;i++)
{(*L).stu[i].total=(*L).stu[i].score[0]+(*L).stu[i].score[1]+(*L).stu[i].score[2];
(*L).stu[i].average=(*L).stu[i].total/3;
}
return OK;
}
void BInsertSort(SqList *L)
{int m;
for(i=2;i<=(*L).length;++i)
{(*L).stu[0]=(*L).stu[i];
low=1;
high=i-1;
while(low<=high)
{m=(low+high)/2;
if(LT((*L).stu[0].seat,(*L).stu[m].seat)) high=m-1;
else low=m+1;
}
for(j=i-1;j>=high+1;--j) (*L).stu[j+1]=(*L).stu[j];
(*L).stu[high+1]=(*L).stu[0];
}
}
int Partion(SqList *L,int low ,int high)
{int pivotkey;
(*L).stu[0]=(*L).stu[low];
pivotkey=(*L).stu[low].total;
while(low {while(low=pivotkey) --high;
(*L).stu[low]=(*L).stu[high];
while(low (*L).stu[high]=(*L).stu[low];
}
(*L).stu[low]=(*L).stu[0];
return low;
}
int QSort(SqList *L, int low,int high)
{int pivotloc;
if(low {pivotloc=Partion(&(*L),low,high);
QSort(&(*L),low,pivotloc-1);
QSort(&(*L),pivotloc+1,high);
}
}
int Com(Dis *S,SqList *L)
{int g;
for(j=0;j<3;j++)
{(*S).sco[j].highest=(*L).stu[1].score[j];
(*S).sco[j].lowest=(*L).stu[1].score[j];
(*S).sco[j].grade=0;
}
(*S).sco[0].nam=1;
(*S).sco[1].nam=2;
(*S).sco[2].nam=3;
for(j=0;j<(*S).len;j++)
{for(i=0;i<(*L).length;i++)
{(*S).sco[j].grade+=(*L).stu[i+1].score[j];
if((*S).sco[j].highest<(*L).stu[i+1].score[j])
(*S).sco[j].highest=(*L).stu[i+1].score[j];
if((*S).sco[j].lowest>(*L).stu[i+1].score[j])
(*S).sco[j].lowest=(*L).stu[i+1].score[j];
}
(*S).sco[j].ave=(*S).sco[j].grade/(*L).length;
}
printf("\nPlease input the discipline:1.Math 2.English 3.Program design");
scanf("%d",&g);
for(i=0;i<3;i++)
if((*S).sco[i].nam==g)
print_3(&(*S),i);
}
print_1(SqList *L)
{int i;
printf("\nseat name sex year Math English Program\n");
for(i=1;i<=(*L).length;i++)
{printf("%d %s %s %d %d %d %d\n",(*L).stu[i].seat,(*L).stu[i].name,(*L).stu[i].sex, (*L).stu[i].year,(*L).stu[i].score[0],(*L).stu[i].score[1],(*L).stu[i].score[2]);
}
return OK;
}
print_2(SqList *L)
{int i;
printf("\nseat name sex year Math English Program total averge\n");
for(i=(*L).length;i>=1;i--)
{printf("%d %s %s %d %d %d %d %d %f\n",(*L).stu[i].seat,(*L).stu[i].name,(*L).stu[i].sex, (*L).stu[i].year,(*L).stu[i].score[0],(*L).stu[i].score[1],(*L).stu[i].score[2],(*L).stu[i].total,(*L).stu[i].average);

}
return OK;
}
print_3(Dis *S,int g)
{printf("\nThe average:%lf",(*S).sco[g].ave);
printf("\nThe highest:%d",(*S).sco[g].highest);
printf("\nThe lowest:%d",(*S).sco[g].lowest);
}
print(SqList *L,int i)
{
printf("\nseat name sex year Math English Program\n");
printf("%d %s %s %d %d %d %d\n",(*L).stu[i].seat,(*L).stu[i].name,(*L).stu[i].sex, (*L).stu[i].year,(*L).stu[i].score[0],(*L).stu[i].score[1],(*L).stu[i].score[2]);

return OK;
}
main()
{SqList L;
Dis S;
int i,j,k;
i=InitList_Sq(&L);
if(i)
{rec s[5]={{103,"zhao","male ",19,80,90,75},
{102,"qian","female",20,85,82,69},
{105,"sun ","male ",20,90,56,81},
{104,"li ","male ",20,89,78,88},
{101,"zhou","female",19,78,79,86}};
for(i=0;i<5;i++)
{L.stu[i+1]=s[i];
}
}
print_1(&L);
while(1)
{printf("Please choose to search:1.Insert 2.delete 3.sort according to xuehao 4.continue");
scanf("%d",&k);
if(k==1)
{Insert(&L);
print_1(&L);
}
if(k==2)
{printf("Please input the student's xue hao you want to delete\n");scanf("%d",&j);
for(i=1;L.stu[i].seat!=j&&i<=L.length;i++);
if(i<=L.length) {Delete(&L,i);print_1(&L);}
else printf("There is none of the person\n");
}
if(k==3)
{BInsertSort(&L);
print_1(&L);
}
if(k==4) break;
getch();
}
List_Sq(&S);
while(1)
{printf("\nPlease choose 1.the sort of total 2.one subject 3.search 4.leave");
scanf("%d",&k);
if(k==1)
{Computing(&L);
QSort(&L,1,L.length);print_2(&L);
}
if(k==2)Com(&S,&L);
if(k==3)
{printf("Please input the student's xue hao you want to search:");scanf("%d",&j);
for(i=1;L.stu[i].seat!=j&&i<=L.length;i++);
if(i<=L.length) print(&L,i);
else printf("There is none of the person\n");
}
if(k==4) break;
}
}还有 这个C语言学得好的话真的很好玩的 要认真学啊同学

游客2

#include
#include
#define LIST_INIT_SIZE 10
#define INCREAMENT 5
#define TRUE 1
#define FALSE 0
#define ERROR 0
#define OVERFLOW -2
#define OK 1
#define LT(a,b) ((a)<(b))
int i,j,low,high;
typedef int Status;
typedef struct
{int seat;
char name[7];
char sex[7];
int year;
int score[3];
int total;
float average;
}rec;
typedef struct
{rec *stu;
int length;
int listsize;
}SqList;
typedef struct
{int grade;
int lowest;
int highest;
double ave;
int nam;
}dis;
typedef struct
{dis *sco;
int len;
int size;
}Dis;
Status InitList_Sq(SqList *L)
{(*L).stu=(rec *)malloc(LIST_INIT_SIZE*sizeof(rec));
if(!(*L).stu) exit (OVERFLOW);
(*L).length=5;
(*L).listsize=10;
return OK;
}
Status List_Sq(Dis *S)
{(*S).sco=(dis *)malloc(LIST_INIT_SIZE*sizeof(dis));
if(!(*S).sco) exit (OVERFLOW);
(*S).len=3;
(*S).size=10;
return OK;
}
Status Insert(SqList *L)
{int g;
printf("\nHow many students you want to input:");
scanf("%d",&g);
for(i=(*L).length+1;i<=(*L).length+g;i++)
{if((*L).listsize<=(*L).length)
{(*L).stu=(int *)realloc((*L).stu,((*L).listsize+INCREAMENT)*sizeof(int));
if(!(*L).stu)exit(OVERFLOW);
(*L).listsize+=INCREAMENT;
}
printf("please input student'纳高infmation:");
printf("\nxue hao:"洞培尺);
scanf("%d",&(*L).stu[i].seat);
printf("\nname:");
scanf("%s",&(*L).stu[i].name);
printf("\nsex:");
scanf("%s",&(*L).stu[i].sex);
printf("\nyear:");
scanf("%d"中升,&(*L).stu[i].year);
printf("\ngrades of three disciplines:");
for(j=0;j<3;j++)
scanf("%d",&(*L).stu[i].score[j]);
}
(*L).length+=g;
}
Status Delete(SqList *L,int i)
{rec *p,*q;
rec *e;
if((i<1)||(i>(*L).length))return ERROR;
p=&((*L).stu[i]);
*e=*p;
q=(*L).stu+(*L).length;
for(++p;p<=q;++p)*(p-1)=*p;
--(*L).length;
return OK;
}
Computing(SqList *L)
{for(i=0;i<=(*L).length;i++)
{(*L).stu[i].total=(*L).stu[i].score[0]+(*L).stu[i].score[1]+(*L).stu[i].score[2];
(*L).stu[i].average=(*L).stu[i].total/3;
}
return OK;
}
void BInsertSort(SqList *L)
{int m;
for(i=2;i<=(*L).length;++i)
{(*L).stu[0]=(*L).stu[i];
low=1;
high=i-1;
while(low<=high)
{m=(low+high)/2;
if(LT((*L).stu[0].seat,(*L).stu[m].seat)) high=m-1;
else low=m+1;
}
for(j=i-1;j>=high+1;--j) (*L).stu[j+1]=(*L).stu[j];
(*L).stu[high+1]=(*L).stu[0];
}
}
int Partion(SqList *L,int low ,int high)
{int pivotkey;
(*L).stu[0]=(*L).stu[low];
pivotkey=(*L).stu[low].total;
while(low {while(low=pivotkey) --high;
(*L).stu[low]=(*L).stu[high];
while(low (*L).stu[high]=(*L).stu[low];
}
(*L).stu[low]=(*L).stu[0];
return low;
}
int QSort(SqList *L, int low,int high)
{int pivotloc;
if(low {pivotloc=Partion(&(*L),low,high);
QSort(&(*L),low,pivotloc-1);
QSort(&(*L),pivotloc+1,high);
}
}
int Com(Dis *S,SqList *L)
{int g;
for(j=0;j<3;j++)
{(*S).sco[j].highest=(*L).stu[1].score[j];
(*S).sco[j].lowest=(*L).stu[1].score[j];
(*S).sco[j].grade=0;
}
(*S).sco[0].nam=1;
(*S).sco[1].nam=2;
(*S).sco[2].nam=3;
for(j=0;j<(*S).len;j++)
{for(i=0;i<(*L).length;i++)
{(*S).sco[j].grade+=(*L).stu[i+1].score[j];
if((*S).sco[j].highest<(*L).stu[i+1].score[j])
(*S).sco[j].highest=(*L).stu[i+1].score[j];
if((*S).sco[j].lowest>(*L).stu[i+1].score[j])
(*S).sco[j].lowest=(*L).stu[i+1].score[j];
}
(*S).sco[j].ave=(*S).sco[j].grade/(*L).length;
}
printf("\nPlease input the discipline:1.Math 2.English 3.Program design");
scanf("%d",&g);
for(i=0;i<3;i++)
if((*S).sco[i].nam==g)
print_3(&(*S),i);
}
print_1(SqList *L)
{int i;
printf("\nseat name sex year Math English Program\n");
for(i=1;i<=(*L).length;i++)
{printf("%d %s %s %d %d %d %d\n",(*L).stu[i].seat,(*L).stu[i].name,(*L).stu[i].sex, (*L).stu[i].year,(*L).stu[i].score[0],(*L).stu[i].score[1],(*L).stu[i].score[2]);
}
return OK;
}
print_2(SqList *L)
{int i;
printf("\nseat name sex year Math English Program total averge\n");
for(i=(*L).length;i>=1;i--)
{printf("%d %s %s %d %d %d %d %d %f\n",(*L).stu[i].seat,(*L).stu[i].name,(*L).stu[i].sex, (*L).stu[i].year,(*L).stu[i].score[0],(*L).stu[i].score[1],(*L).stu[i].score[2],(*L).stu[i].total,(*L).stu[i].average);

}
return OK;
}
print_3(Dis *S,int g)
{printf("\nThe average:%lf",(*S).sco[g].ave);
printf("\nThe highest:%d",(*S).sco[g].highest);
printf("\nThe lowest:%d",(*S).sco[g].lowest);
}
print(SqList *L,int i)
{
printf("\nseat name sex year Math English Program\n");
printf("%d %s %s %d %d %d %d\n",(*L).stu[i].seat,(*L).stu[i].name,(*L).stu[i].sex, (*L).stu[i].year,(*L).stu[i].score[0],(*L).stu[i].score[1],(*L).stu[i].score[2]);

return OK;
}
main()
{SqList L;
Dis S;
int i,j,k;
i=InitList_Sq(&L);
if(i)
{rec s[5]={{103,"zhao","male ",19,80,90,75},
{102,"qian","female",20,85,82,69},
{105,"sun ","male ",20,90,56,81},
{104,"li ","male ",20,89,78,88},
{101,"zhou","female",19,78,79,86}};
for(i=0;i<5;i++)
{L.stu[i+1]=s[i];
}
}
print_1(&L);
while(1)
{printf("Please choose to search:1.Insert 2.delete 3.sort according to xuehao 4.continue");
scanf("%d",&k);
if(k==1)
{Insert(&L);
print_1(&L);
}
if(k==2)
{printf("Please input the student's xue hao you want to delete\n");scanf("%d",&j);
for(i=1;L.stu[i].seat!=j&&i<=L.length;i++);
if(i<=L.length) {Delete(&L,i);print_1(&L);}
else printf("There is none of the person\n");
}
if(k==3)
{BInsertSort(&L);
print_1(&L);
}
if(k==4) break;
getch();
}
List_Sq(&S);
while(1)
{printf("\nPlease choose 1.the sort of total 2.one subject 3.search 4.leave");
scanf("%d",&k);
if(k==1)
{Computing(&L);
QSort(&L,1,L.length);print_2(&L);
}
if(k==2)Com(&S,&L);
if(k==3)
{printf("Please input the student's xue hao you want to search:");scanf("%d",&j);
for(i=1;L.stu[i].seat!=j&&i<=L.length;i++);
if(i<=L.length) print(&L,i);
else printf("There is none of the person\n");
}
if(k==4) break;
}
}

游客3

好可怕啊,还好没学

游客4

额???

游客5

留个邮箱

发给你