急。要交的程序,好心人帮忙调试一下,在线等。谢谢。
#include<stdio.h>#define TERM 7
#define CLAS 7
#define ORDER 3
struct Student
{
char number[8];
char name[10];
int score;
int sum;
int average;
int order;
};
struct Student student[TERM][CLAS][ORDER];
void input()
{
int i,j,k;
for(i=1;i<=TERM;i++)
for(j=1;j<=CLAS;j++)
for(k=1;k<=ORDER;k++)
{
printf("Please input the student[%d][%d][%d] number\n",i,j,k);
scanf("%s",student[i][j][k].number);
printf("Please input the student[%d][%d][%d] name\n",i,j,k);
scanf("%s",student[i][j][k].name);
printf("Please input the student[%d][%d][%d] score\n",i,j,k);
scanf("%s",student[i][j][k].score);
}
}
void sumscore()
{
int i,j,k;
for(j=1;j<=CLAS;j++)
for(k=1;k<=ORDER;k++)
for(i=1;i<=TERM;i++)
{
student[i][j][k].sum= student[i][j][k].sum+ student[i][j][k].score;
printf(" student[%d][%d][%d] sum score is:%d",i,j,k, student[k][i][j].sum);
}
}
void averagescore()
{
int i,j,k;
for(j=1;j<=CLAS;j++)
for(k=1;k<=ORDER;k++)
for(i=1;i<=TERM;i++)
{
student[i][j][k].sum= student[i][j][k].sum+ student[i][j][k].score;
student[i][j][k].average= student[i][j][k].sum/TERM;
printf(" student[%d][%d][%d] average score is:%d",i,j,k, student[i][j][k].average);
}
}
void allorder()
{
int i=6,j,k,m,n;
int sam[CLAS*ORDER];
int a=1;
int t;
for(j=1;j<=CLAS;j++)
for(k=1;k<=ORDER;k++)
{
sam[a]=student[i][j][k].score;
a++;
}
for(a=1;a<=CLAS*ORDER;a++)
for(n=1;n<CLAS*ORDER-a;n++)
{
if(sam[a]<sam[a++])
{
sam[a]=t;
sam[a]=sam[a++];
t=sam[a++];
sam[a]=student[i][j][k].order;
}
printf("the order is:sam[%d]:%d student[%d][%d]:%d\n",a,student[i][j][k].order);
}
}
void findnumber()
{
int i,j,k;
char c;
printf("Please input the student's number:");
scanf("%s",&c);
printf("\n");
for(i=1;i<=TERM;i++)
for(j=1;j<=CLAS;j++)
for(k=1;k<=ORDER;k++)
{
if(c==student[i][j][k].number)
{
printf("the student's information is:\n");
printf("term:%d clas:%d number:%s name:%s score:%d\n",i,j,k,student[i][j][k].number,student[i][j][k].name,student[i][j][k].score);
printf("average score:%d order:%d",student[i][j][k].average,student[i][j][k].order);
printf("\n");
}
else printf("The number is error.\n");
}
}
void findname()
{
int i,j,k;
char d;
printf("Please input the student's name:");
scanf("%s",&d);
printf("\n");
for(i=1;i<=TERM;i++)
for(j=1;j<=CLAS;j++)
for(k=1;k<=ORDER;k++)
{
if(d==student[i][j][k].name)
{
printf("the student's information is:\n");
printf("term:%d clas:%d number:%s name:%s score:%d\n",i,j,k,student[i][j][k].number,student[i][j][k].name,student[i][j][k].score);
printf("average score:%d order:%d",student[i][j][k].average,student[i][j][k].order);
printf("\n");
}
else printf("The name is error.\n");
}
}
void unfinash()
{
int i=6;
int j,k,f;
printf("Please inpue the score line:");
scanf("%d",&f);
printf("/n");
for(j=1;j<=CLAS;j++)
for(k=1;k<=ORDER;k++)
{
if(student[i][j][k].order>=f)
printf("finash\n");
else printf("unfinash\n");
printf("the student's information is:\n");
printf("term:%d clas:%d number:%s name:%s score:%d\n",i,j,k,student[i][j][k].number,student[i][j][k].name,student[i][j][k].score);
printf("average score:%d order:%d",student[i][j][k].average,student[i][j][k].order);
}
}
void findclass()
{
int i,j,k,e;
printf("Please input the class(1-6):");
scanf("%d",&e);
printf("\n");
for(i=1;i<=TERM;i++)
for(k=1;k<=ORDER;k++)
printf("the class %d information is:\n",e);
{
for(i=1;i<=TERM;i++)
for(k=1;k<=ORDER;k++)
printf("number:student[%d][%d][%d].number name:student[%d][%d][%d].name score:student[%d][%d][%d].score",i,e,k);
}
}
void output()
{
int o;
printf("*********the system of the information of the student********\n");
printf("the function include:\n");
printf("1.you can input the students' information.\n");
printf("2.you can count the all of the score of every student according to term.\n");
printf("3.you can count the average of the score of every student.\n");
printf("4.you can order the student according to the all of the score\n");
printf("5.you can find the information of the student according to number.\n");
printf("6.you can find the information of the student according to name.\n");
printf("7.you can find the information of the student who do not finash the score.\n");
printf("8.you can find the information of the student according to class.\n");
printf("1.If you want input the students' information,please input '1'.\n");
printf("2.If you want to know the all of the score of every student,please input '2'.\n");
printf("3.If you want to know the average of the score,please input '3'.\n");
printf("4.If you want to know the order of the student according score,please input '4'.\n");
printf("5.If you want to know the information of the student accordind to number,please input '5'.\n");
printf("6.If you want to know the information of the student accordind to name,please input '6'.\n");
printf("7.If you want to know the information of the student who do not finash the score,please input '7'.\n");
printf("8.If you want to know the information of the student accordind to class,please input '8'.\n");
printf("Please input the massage:\n");
scanf("%d",o);
printf("\n");
}
void main()
{
int o;
void output();
if(o==1) void input();
else if(o==2) void allscore();
else if(o==3) void averagescore();
else if(o==4) void sumorder();
else if(o==5) void findnumber();
else if(o==6) void findname();
else if(o==7) void unfinash();
else if(o==8) void findclass();
}