C语言大作业——学生成绩管理系统v2.0

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

//成绩管理系统v2.0

#include

#include

#define N 30

void Input (long num[],int score[],int n);

void Totalave (int score[],int n);

void Scoredes (long num[],int score[],int n,int (*compare)(int a,int b)); int Ascending (int a,int b);

void Numas (long num[],int score[],int n);

void Search (long num[],int score[],int n,int x);

void statistis (long num[],int score[],int n);

void List (long num[],int score[],int n);

int main()

{

int n,score[N],c,x,i;

long num[N];

printf("输入学生人数");

scanf("%d",&n);

printf("1.Input record\n");

printf("2.Caculate totel and average score of course\n");

printf("3.Sort in descending order by score\n");

printf("4.Sort in ascending order by number\n");

printf("5.Search by number\n");

printf("6.Statistic analysis\n");

printf("7.List record\n");

printf("0.Exit\n");

printf("Please enter your choice:\n");

printf("\n");

for(;;)

{

scanf("%d",&c);

switch(c)

{

case 1:

Input (num,score,n);

printf("Please enter your choice:\n");

break;

case 2:

Totalave (score,n);

printf("Please enter your choice:\n");

break;

case 3:

Scoredes (num,score,n,Ascending);

for(i=0;i

printf("ID:%10ld,score:%d\n",num[i],score[i]);//以长整形打印用%ld printf("Please enter your choice:\n");

break;

case 4:

Numas (num,score,n);

printf("Please enter your choice:\n");

break;

case 5:

printf("请输入查找学号\n");

scanf("%d",&x);

Search (num,score,n,x);

printf("Please enter your choice:\n");

break;

case 6:

statistis (num,score,n);

printf("Please enter your choice:\n");

break;

case 7:

List (num,score,n);

Totalave (score,n);

printf("Please enter your choice:\n");

break;

case 0:

exit(0);

}

}

return 0;

}

void Input (long num[],int score[],int n)

{

int i;

for(i=0;i

{

printf("Input student's ID and score");

scanf("%ld%d",&num[i],&score[i]);

}

}

void Totalave (int score[],int n)

{

int i,sum=0;

double ave;

for(i=0;i

sum=sum+score[i];

ave=(double)sum/n;

printf("Caculate total=%d,average score of course=%f\n",sum,ave); }

void Scoredes (long num[],int score[],int n,int(*compare)(int a,int b)) {

int i,j,k,t,h;

for(i=0;i

{

k=i;

for(j=i+1;j

{

if ((*compare)(score[j],score[k]))

k=j;

}

if(i!=k)

{

t=score[k],h=num[k];

score[k]=score[i],num[k]=num[i];

score[i]=t,num[i]=h;

}

}

}

int Ascending (int a,int b)

{

return a

}

void Numas (long num[],int score[],int n)

{

int i,j,k,t,h;

for(i=0;i

{

k=i;

for(j=i+1;j

{

if (num[j]

k=j;

}

if(i!=k)

{

t=score[k],h=num[k];

score[k]=score[i],num[k]=num[i];

score[i]=t,num[i]=h;

}

}

for(i=0;i

相关文档
最新文档