学生个人信息成绩管理系统(c语言动态链表不限定输入学生人数可查询保存的信

时间:2025-05-10

c语言,期末课程设计作业,动态链表,不限定输入学生人数,可实现输入信息,查询信息,求某院系,某班级,某学科的平均分,最高最低分,可输出班级排名。

//主模块
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#define LEN sizeof(struct stu)

struct stu
{
int long num;
char name[20];
char college[20];
char Class[20]; //注意,class小写不能用,特定义为Class
char subject[20];
float score;
struct stu *next;
};




int n,i,checknum; //作为计数变量
struct stu *head,*temp; //链表头
struct stu *p1,*p2,*p3,*p4; //
struct stu *p,*a;
struct stu *head2,*head3;
struct stu array[100];
char array2[4][20];

struct stu *creat(void) //创建链表的函数,并输入学生信息
{
n=0;
head=NULL;

do
{ p1=(struct stu * ) malloc(LEN);

do
{ checknum=scanf("%d",&p1->num); //分两步进行输入,中间判断一下num是否为0,是则退出
if (checknum==0) //checknum作为返回值,检验num是否存入数字,
printf("输入错误,请检查输入的数据后重新输入 ");
else break;
fflush(stdin);
} while (checknum==0);
if ((p1->num)==0) break;
scanf ("%s%s%s%s%f",p1->name,p1->college,p1->Class,p1->subject,&p1->score);


n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
}while (p1->num!=0);
p2->next=NULL;
return(head);
}

void save()

{ n=0;
if (head!=NULL)
do
{ n=n+1;
if (n==1)
p=head;
else p=p->next;

}while ((p->next)!=NULL);

}

void find()
{
char x[20];
scanf("%s",x);
printf("输出:%s\n",x);


n=0;
if (head!=NULL)
do
{ n=n+1;
if(n==1) a=head;
else a=a->next;



if (strcmp (x,a->college)==0)
printf("输出:%12d%10s%18s%10s%10s%5.1f\n",a->num,a->name,a->college,a->Class,a->subject,a->score);

if (strcmp (x,a->Class)==0)
printf("输出:%12d%10s%18s%10s%10s%5.1f\n",a->num,a->name,a->college,a->Class,a->subject,a->score);

if (strcmp (x,a->subject)==0)
printf("输出:%12d%10s%18s%10s%10s%5.1f\n",a->num,a->name,a->college,a->Class,a->subject,a->score);

}while ((a->next)!=NULL);

}

void print(struct stu *head) //输出数据从文件stu.dat
{

n=0;
if (head!=NULL)
do
{ n=n+1;
if(n==1) a=head;
else a=a->next;

printf("输出二:%12d%10s%18s%10s%10s%5.1f\n",a->num,a->name,a->college,a->Class,a->subject,a->score);
}while ((a->next)!=NU
LL); //切记是a->next 而不是a

}

void New()
{

char x[20];
scanf("%s",x);

n=i=0;
p=NULL;
if (head!=NULL)

c语言,期末课程设计作业,动态链表,不限定输入学生人数,可实现输入信息,查询信息,求某院系,某班级,某学科的平均分,最高最低分,可输出班级排名。

do
{ n=n+1;
if(n==1) a=head;
else a=a->next;

if ((strcmp (x,a->college)==0)||(strcmp (x,a->Class)==0)||(strcmp (x,a->subject)==0))
{ i=i+1;
if (i==1) p=head2=a;

else p->next=a;
p=a;
}
}while ((a->next)!=NULL);
p->next=NULL;
}

void New2()
{
char x[20];
scanf("%s",x);
printf("输出:%s\n",x);

n=i=0;
p=NULL;
if (head2!=NULL)
do
{ n=n+1;
if(n==1) a=head2;
else a=a->next;

if ((strcmp (x,a->college)==0)||(strcmp (x,a->Class)==0)||(strcmp (x,a->subject)==0))
{ i=i+1;
if (i==1) p=head3=a;

else p->next=a;
p=a;
}
}while ((a->next)!=NULL);
p->next=NULL;
}

void average ()
{

float sumnum,avenum;
n=i=0;
if (head2!=NULL)
do
{ n=n+1;
i=i+1;
if(n==1) a=head2;
else a=a->next;
if(i==1) sumnum=a->score;
else sumnum=sumnum+a->score;

}while ((a->next)!=NULL);

avenum=sumnum/i;
printf("平均分数为%5.1f\t",avenum);


}


void pass()
{
float passnum,prenum;
float j1,j2,j3;
j1=j2=j3=0;



if (head2!=NULL)
do
{ j1=j1+1;

if(j1==1) a=head2;
else a=a->next;
if(a->score>=60&&a->score<=100) j2=j2+1;
if(a->score>=90&&a->score<=100) j3=j3+1;

}while ((a->next)!=NULL);

passnum=j2/j1*100;
prenum=j3/j1*100;
printf("通过率为%5.0f%%\t优秀率为%5.0f%%\n",passnum,prenum);




}



void max()
{
float maxnum=0;
n=i=0;
if (head2!=NULL)
do
{ n=n+1;
if(n==1) a=head2;
else a=a->next;
if(a->score>maxnum) maxnum=a->score;

}while ((a->next)!=NULL);


printf("最大值为%5.1f\t",maxnum);

}
void min()
{
float minnum=100;
n=i=0;
if …… 此处隐藏:4342字,全部文档内容请下载后查看。喜欢就下载吧 ……

学生个人信息成绩管理系统(c语言动态链表不限定输入学生人数可查询保存的信.doc 将本文的Word文档下载到电脑

    精彩图片

    热门精选

    大家正在看

    × 游客快捷下载通道(下载后可以自由复制和排版)

    限时特价:7 元/份 原价:20元

    支付方式:

    开通VIP包月会员 特价:29元/月

    注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
    微信:fanwen365 QQ:370150219