简单学生成绩管理信息系统
学生成绩信息包括:学号,姓名,课程名,平时成绩,实验成绩,考试成绩,总评成绩。
实现如下功能:
1) 能够实现学生成绩信息的插入、删除和修改;
2) 能够实现各种查询(分别根据学生学号、姓名、课程名称等);
3) 能够实现按照考试成绩、总评成绩进行排序;
4) 能够查询某门课程的最高分、最低分并输出相应学生信息;
5) 能够查询某门课程的优秀率(90 分及以上)、不及格率;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student
{
int number;
char name[20];
char banji[20];
char course[20];
int pscore;
int kscore;
int sumsore;
struct student *next;
} ;
struct student *create() //先构造一个结构体
{
struct student *head;
struct student *p1;
p1=(struct student*)malloc(sizeof(struct student)); //申请一个空间
head=p1;
printf("\n学生信息\n"); //输入学生的信息
printf("学号:");
scanf("%d",&p1->number);
printf("姓名:");
scanf("%s",p1->name);
printf("班级:");
scanf("%s",p1->banji);
printf("课程名:");
scanf("%s",p1->course);
printf("平时成绩:");
scanf("%d",&p1->pscore);
printf("考试成绩:");
scanf("%d",&p1->kscore);
printf("总评成绩:");
scanf("%d",&p1->sumsore);
return head;
}
struct student *input(int n) //输入学生信息
{
int i;
char y ;
struct student *head,*pt,*p;
head=pt;
p=(struct student*)malloc(sizeof(struct student)); //申请一个空间
if(i!=1) //判断是不是第一空间
{
for(i=1;i<n;i++)
{
pt=pt->next;
}
pt->next=create();
}
else
{
pt=create();
}
pt=pt->next;
pt->next=p;
pt=pt->next;
pt->next=NULL;
return head;
}
void amend(struct student *head) //修改学生信息
{
int m,k,fale=0;
char z;
struct student *p;
do
{
p=head;
printf("请输入要修改的学生的学号:");
scanf("%d",&m);
do
{
if(p->number==m) //寻找该学号的学生
{
printf("学号:%d\n姓名:%s\n班级:%s\n课程名:%s\n平时成绩:%d\n考试成绩:%d\n总评成绩:%d\n",p->number,p->name,p->banji,p->course,p->pscore,p->kscore,p->sumsore);
printf("\n1.学号\n2.姓名\n3.班级\n4.课程名\n5.平时成绩\n6.考试成绩\n7.总评成绩\n0.不修改");
printf("\n请输入要修改:");
scanf("%d",&k);
printf("修改为:");
switch(k) //对学生学号进行修改
{
case 1:scanf("%d",&p->number);break;
case 2:scanf("%s",p->name);break;
case 3:scanf("%s",p->banji);break;
case 4:scanf("%s",p->course);break;
case 5:scanf("%d",&p->pscore);break;
case 6:scanf("%d",&p->kscore);break;
case 7:scanf("%d",&p->sumsore);break;
case 0:break;
};
fale=1;
break;
}
p=p->next;
}while(p->next!=NULL);
if(fale==0) printf("没有查找到这个人。\n");
printf("是否继续修改(Y/N):"); //是否还进行修改的判断
getchar();
scanf ("%c",&z);
}while(z!='n'&&z!='N');
}
void camcel(struct student *head) // 删除学生信息
{
int i=1,m,k,fale=0;
char z;
struct student *p,*pt;
do
{
p=head;
pt=head;
p=p->next;
printf("请输入要删除的学生的学号:");
scanf("%d",&m);
do
{
if(p->number==m) //寻找该学生
{
printf("学号:%d\n姓名:%s\n班级:%s\n课程名:%s\n平时成绩:%d\n考试成绩:%d\n总评成绩:%d\n",p->number,p->name,p->banji,p->course,p->pscore,p->kscore,p->sumsore);
printf("\n是否要删除(Y/N):");
getchar();
scanf("%c",&k);
if(k=='y'||k=='Y') //对学生删除的操作
{
if(i==1) //先判断是否是第一个学生
{
head->next=p->next;
}
else
{
do
{
pt=pt->next;
}while(pt->next!=p);
pt->next=p->next;
free(p);
}
}
fale=1;
break;
}
i++;
p=p->next;
}while(p->next!=NULL);
if(fale==0) printf("没有查找到这个人。\n");
printf("是否继续修改(Y/N):");
getchar();
scanf ("%c",&z);
}while(z!='n'&&z!='N');
}
void xingmingchaxun(struct student *head) //按姓名查询
{
struct student *p;
char a[20],c;
int fale=0;
do
{
p=head;
printf("输入要查找的姓名:");
scanf("%s",a);
do
{
if(strcmp(p->name,a)==0)
{
printf("学号:%d 姓名:%s 班级:%s 课程名:%s 平时成绩:%d 考试成绩:%d 总评成绩:%d \n",p->number,p->name,p->banji,p->course,p->pscore,p->kscore,p->sumsore);
fale=1;
c=1;
}
p=p->next;
}while(p!=NULL);
if(fale==0) printf("\n没有查找到该学生\n");
printf("\n\n是否继续查找(Y/N):");
getchar();
scanf ("%c",&c);
}while(c!='n'&&c!='N');
}
void kechengchaxun(struct student *head)// 按课程名称查询
{
struct student *p;
char a[20],c;
int fale=0;
do
{
p=head;
printf("\n输入要查找的课程:");
scanf("%s",a);
do
{
if(strcmp(p->course,a)==0)
{
printf("学号:%d 姓名:%s 班级:%s 课程名:%s 平时成绩:%d 考试成绩:%d 总评成绩:%d \n",p->number,p->name,p->banji,p->course,p->pscore,p->kscore,p->sumsore);
fale=1;
c=1;
}
p=p->next;
}while(p!=NULL);
if(fale==0) printf("\n没有查找到该课程\n");
printf("\n\n是否继续查找(Y/N):");
getchar();
scanf ("%c",&c);
}while(c!='n'&&c!='N');
}
void xuehaochaxun(struct student *head) // 按学号查询
{
struct student *p;
char c;
int a,fale=0;
do
{
p=head;
printf("\n输入要查找的学号:");
scanf("%d",&a);
do
{
if(p->number==a)
{
printf("学号:%d 姓名:%s 班级:%s 课程名:%s 平时成绩:%d 考试成绩:%d 总评成绩:%d \n ",p->number,p->name,p->banji,p->course,p->pscore,p->kscore,p->sumsore);
fale=1;
c=1;
}
p=p->next;
}while(p!=NULL);
if(fale==0) printf("\n没有查找到该学号的学生\n");
printf("\n\n是否继续查找(Y/N):");
getchar();
scanf ("%c",&c);
}while(c!='n'&&c!='N');
}
void banjichaxun(struct student *head) //按班级查询
{
struct student *p;
char a[20],c;
int fale=0;
do
{
p=head;
printf("\n输入要查找的班级:");
scanf("%s",a);
do
{
if(strcmp(p->banji,a)==0)
{
printf("学号:%d 姓名:%s 班级:%s 课程名:%s 平时成绩:%d 考试成绩:%d 总评成绩:%d ",p->number,p->name,p->banji,p->course,p->pscore,p->kscore,p->sumsore);
fale=1;
c=1;
}
p=p->next;
}while(p!=NULL);
if(fale==0) printf("\n没有查找到该班级\n");
printf("\n\n是否继续查找(Y/N):");
getchar();
scanf ("%c",&c);
}while(c!='n'&&c!='N');
}
void youxiulv(struct student *head) //查询班级优秀率
{
struct student *p;
char a[20],c;
float n=0,m=-2;
do
{
p=head;
printf("\n输入要查找的优秀率的科目:");
scanf("%s",a);
do
{
if(strcmp(p->course,a)==0)
{
if(p->sumsore>=80)
n++;
}
m++;
p=p->next;
}while(p!=NULL);
printf("该目的优秀率为:%0.2f",n/m) ;
printf("\n\n是否继续查找(Y/N):");
getchar();
scanf ("%c",&c);
}while(c!='n'&&c!='N');
}
void zongfengpaixu(struct student *head,int n) //按总分高低排序
{
char c;
int i,j;
struct student *p,temp;
struct student a[n];
p=head;
p=p->next;
for(i=0;i<=n-1;i++)
{
a[i].number=p->number;
strcpy(a[i].name,p->name);
strcpy(a[i].banji,p->banji);
strcpy(a[i].course,p->course);
a[i].pscore=p->pscore;
a[i].kscore=p->kscore;
a[i].sumsore=p->sumsore;
p=p->next;
}
for(i=0;i<=n-1;i++) //冒泡法来排列顺序
{
for(j=0;j<=n-2;j++)
{
if(a[j].sumsore<a[j+1].sumsore)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("Nes:\n");
do
{
for(i=0;i<n;i++)
{
printf("学号:%d 姓名:%s 班级:%s 课程名:%s 平时成绩:%d 考试成绩:%d 总评成绩:%d \n",a[i].number,a[i].name,a[i].banji,a[i].course,a[i].pscore,a[i].kscore,a[i].sumsore);
}
printf("\n\n是否退出(Y/N):");
getchar();
scanf ("%c",&c);
}while(c!='y'&&c!='Y');
}
void dankechengjipaiming(struct student *head,int n) //单科成绩排名
{
char c,b[20];
int i,j,m;
struct student *p,temp;
struct student a[n];
do
{
m=0;
p=head;
p=p->next;
printf("输入要查找的科目:");
scanf("%s",b);
for(i=0;i<=n-1;i++)
{
if(strcmp(p->course,b)==0)
{
a[m].number=p->number;
strcpy(a[m].name,p->name);
strcpy(a[m].banji,p->banji);
strcpy(a[m].course,p->course);
a[m].pscore=p->pscore;
a[m].kscore=p->kscore;
a[m].sumsore=p->sumsore;
m++;
}
p=p->next;
}
for(i=0;i<=m-1;i++) //冒泡法来排列顺序
{
for(j=0;j<=m-2;j++)
{
if(a[j].sumsore<a[j+1].sumsore)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("Nes:\n");
for(i=0;i<m;i++)
{
printf("学号:%d 姓名:%s 班级:%s 课程名:%s 平时成绩:%d 考试成绩:%d 总评成绩:%d \n",a[i].number,a[i].name,a[i].banji,a[i].course,a[i].pscore,a[i].kscore,a[i].sumsore);
}
printf("\n\n是否退出(Y/N):");
getchar();
scanf ("%c",&c);
}while(c!='y'&&c!='Y');
}
void pingshifengpaiming(struct student *head,int n)
{
char c;
int i,j;
struct student *p,temp;
struct student a[n];
p=head;
p=p->next;
for(i=0;i<=n-1;i++)
{
a[i].number=p->number;
strcpy(a[i].name,p->name);
strcpy(a[i].banji,p->banji);
strcpy(a[i].course,p->course);
a[i].pscore=p->pscore;
a[i].kscore=p->kscore;
a[i].sumsore=p->sumsore;
p=p->next;
}
for(i=0;i<=n-1;i++) //冒泡法来排列顺序
{
for(j=0;j<=n-2;j++)
{
if(a[j].pscore<a[j+1].pscore)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("Nes:\n");
do
{
for(i=0;i<n;i++)
{
printf("学号:%d 姓名:%s 班级:%s 课程名:%s 平时成绩:%d 考试成绩:%d 总评成绩:%d \n",a[i].number,a[i].name,a[i].banji,a[i].course,a[i].pscore,a[i].kscore,a[i].sumsore);
}
printf("\n\n是否退出(Y/N):");
getchar();
scanf ("%c",&c);
}while(c!='y'&&c!='Y');
}
void kaoshifengpaiming(struct student *head,int n)
{
char c;
int i,j;
struct student *p,temp;
struct student a[n];
p=head;
p=p->next;
for(i=0;i<=n-1;i++)
{
a[i].number=p->number;
strcpy(a[i].name,p->name);
strcpy(a[i].banji,p->banji);
strcpy(a[i].course,p->course);
a[i].pscore=p->pscore;
a[i].kscore=p->kscore;
a[i].sumsore=p->sumsore;
p=p->next;
}
for(i=0;i<=n-1;i++) //冒泡法来排列顺序
{
for(j=0;j<=n-2;j++)
{
if(a[j].kscore<a[j+1].kscore)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("Nes:\n");
do
{
for(i=0;i<n;i++)
{
printf("学号:%d 姓名:%s 班级:%s 课程名:%s 平时成绩:%d 考试成绩:%d 总评成绩:%d \n",a[i].number,a[i].name,a[i].banji,a[i].course,a[i].pscore,a[i].kscore,a[i].sumsore);
}
printf("\n\n是否退出(Y/N):");
getchar();
scanf ("%c",&c);
}while(c!='y'&&c!='Y');
}
void pingshichengjichaxun(struct student *head,int n)
{
struct student *p;
char c;
int a,fale=0;
do
{
p=head;
printf("\n输入要查找的平时成绩:");
scanf("%d",a);
do
{
if(a==p->pscore)
{
printf("学号:%d 姓名:%s 班级:%s 课程名:%s 平时成绩:%d 考试成绩:%d 总评成绩:%d \n",p->number,p->name,p->banji,p->course,p->pscore,p->kscore,p->sumsore);
fale=1;
c=1;
}
p=p->next;
}while(p!=NULL);
if(fale==0) printf("\n没有查找到该成绩\n");
printf("\n\n是否继续查找(Y/N):");
getchar();
scanf ("%c",&c);
}while(c!='n'&&c!='N');
}
void kaoshichengjichaxun(struct student *head,int n)
{
struct student *p;
char c;
int a,fale=0;
do
{
p=head;
printf("\n输入要查找的考试成绩:");
scanf("%d",a);
do
{
if(a==p->kscore)
{
printf("学号:%d 姓名:%s 班级:%s 课程名:%s 平时成绩:%d 考试成绩:%d 总评成绩:%d \n",p->number,p->name,p->banji,p->course,p->pscore,p->kscore,p->sumsore);
fale=1;
c=1;
}
p=p->next;
}while(p!=NULL);
if(fale==0) printf("\n没有查找到该成绩\n");
printf("\n\n是否继续查找(Y/N):");
getchar();
scanf ("%c",&c);
}while(c!='n'&&c!='N');
}
int jisuan(char a[])
{
int i,sum=0;
for(i=0;a[i]!='\0';i++)
{
if(i==0)
{
sum=a[i]-'0';
}
else
{
sum=sum*10+(a[i]-'0');
}
}
return sum;
}
int main()
{
int n=0,ch=0,th=0;
int *q;
q=&n;
struct student *intput_shuji(int *m);
struct student *create() ;
struct student *input(int n);
void amend(struct student *head) ;
void camcel(struct student *head);
void xingmingchaxun(struct student *head);
void kechengchaxun(struct student *head);
void xuehaochaxun(struct student *head);
void banjichaxun(struct student *head);
void youxiulv(struct student *head);
void zongfengpaixu(struct student *head,int n);
void dankechengjipaiming(struct student *head,int n);
void pingshifengpaiming(struct student *head,int n);
void kaoshifengpaiming(struct student *head,int n);
void pingshichengjichaxun(struct student *head,int n);
void kaoshichengjichaxun(struct student *head,int n);
struct student *head;
do
{
printf("学生成绩管理系统\n\n");
printf("1.学生数据输入\n2.学生数据修改\n3.学生数据查找\n4.学生排名\n5.退出系统") ;
printf("\n----------------------------------------\n") ;
printf("\n要进行的步骤");
scanf("%d",&ch) ;
system("cls");
switch(ch)
{
case 1:{
n++;
head=input(n);
break;
}
case 2:{
do
{
printf("\n1.修改学生信息\n2.删除学生信息\n3.返回上一层\n");
printf("\n要进行的步骤:");
scanf("%d",&th);
switch(th)
{
case 1: amend(head);;break;
case 2:{
camcel(head);
n--;
break;
}
}
system("cls");
}while(th!=3);
break;
}
case 3:{
do
{
printf("\n1.按姓名查询\n2.按班级查询\n3.按学号查询\n4.按课程名称查询\n5.按平时成绩查询\n6.按考试成绩查询\n7.按总成绩查询\n8.返回上一层\n");
printf("\n要进行的步骤:");
scanf("%d",&th);
switch(th)
{
case 1:xingmingchaxun(head);break;
case 2:banjichaxun(head); break;
case 3:xuehaochaxun(head);break;
case 4:kechengchaxun(head);break;
case 5:pingshichengjichaxun(head,n);break;
case 6:kaoshichengjichaxun(head,n);break;
case 7:zongfengpaixu(head,n);break;
}
system("cls");
}while(th!=8);
break;
}
case 4:{
do
{
printf("\n1.按总分高低排序\n2.单科成绩排名\n3.平时分排名\n4.考试分排名\n5.查询班级优秀率\n6.返回上一层\n");
printf("\n要进行的步骤:");
scanf("%d",&th);
switch(th)
{
case 1:zongfengpaixu(head,n);break;
case 2: dankechengjipaiming(head,n);break;
case 3:pingshifengpaiming(head,n);break;
case 4:kaoshifengpaiming(head,n);break;
case 5: youxiulv(head); break;
}
system("cls");
}while(th!=6);
}
break;
}
system("cls");
}while(ch!=5) ;
return 0;
}
776





