能不能帮我看一下,这个哪里有出错吗?
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include "string.h"
#define N 3
struct student
{ long int number;
char name[10];
float s[5],sum,ave;
}temp,stu[N]= {{10010,"lin",1,1,1,1,1},
{10011,"huang",0,0,0,0,0},
{10012,"cheng",2,2,2,2,2}
};
void print(struct student stu[ ],int i)
{ int j;
printf("||number|| name||\n");
printf("||%ld ||%8s||\n",stu[i].number,stu[i].name);
for (j=0;j<5;j++)
printf("score%d=:%8.1f\n",j+1,stu[i].s[j]);
printf("\n");
}
void Input(struct student stu[ ],int i)
{ int j;
float k;
printf("Please input the student's number=:");
scanf("%ld",&stu[i].number);
printf("Please input the student's name=:");
scanf("%s",&stu[i].name);
for (j=0;j<5;j++)
{printf("Please input the student's score%d=:",j+1);
scanf("%f",&k);
stu[i].s[j]=k;
}
print(stu,i);
}
void Add(struct student stu[ ],int i)
{ int j;
float k;
printf("Please input the student's number=:");
scanf("%ld",&stu[i+N-1].number);
printf("Please input the student's name=:");
scanf("%s",&stu[i+N-1].name);
for (j=0;j<5;j++)
{printf("Please input the student's score%d=:",j+1);
scanf("%f",&k);
stu[i+N-1].s[j]=k;
}
for(j=0;j<N+1;j++)
{print(stu,j);}
}
void Change(struct student stu[ ],int i)
{ int j,k;
long int m;
float p;
printf("Please input the student's number:\n");
scanf("%ld",&m);
for(j=0;j<N;j++)
{ if (stu[j].number==m)
{ k=j;
print(stu,j);
printf("\n");
}
}
do
{printf("\t\t\t*** 1.Change the student's score1 ***\t\t\t\n");
printf("\t\t\t*** 2.Change the student's score2 ***\t\t\t\n");
printf("\t\t\t*** 3.Change the student's score3 ***\t\t\t\n");
printf("\t\t\t*** 4.Change the student's score4 ***\t\t\t\n");
printf("\t\t\t*** 5.Change the student's score5 ***\t\t\t\n");
printf("Please input i=:\n");
scanf("%d",&i);
switch (i)
{ case 1:printf("Please input the student's score1:\n");
scanf("%f",&p);
stu[k].s[0]=p;
print(stu,k);break;
case 2:printf("Please input the student's score2:\n");
scanf("%f",&p);
stu[k].s[1]=p;
print(stu,k);break;
case 3:printf("Please input the student's score3:\n");
scanf("%f",&p);
stu[k].s[2]=p;
print(stu,k);break;
case 4:printf("Please input the student's score4:\n");
scanf("%f",&p);
stu[k].s[3]=p;
print(stu,k);break;
case 5:printf("Please input the student's score5:\n");
scanf("%f",&p);
stu[k].s[4]=p;
print(stu,k);break;
}}while (i!=0);
printf("please wait input any key continue");
getch();
}
void Delete (struct student stu[ ],int i)
{ long int m;
printf("Please input the student's number=:\n");
scanf("%ld",&m);
for(i=0;i<N;i++)
{ if (stu[i].number==m)
{ stu[i]=stu[i+1];
}
}
for(i=0;i<N-1;i++)
{ print(stu,i);
}
}
void Inquire(struct student stu[ ],int i)
{ long int m;
printf("Please input the student's number=:\n");
scanf("%ld",&m);
for(i=0;i<N;i++)
{ if (stu[i].number==m)
{ print(stu,i);
}
}
printf("please wait input any key continue");
getch();
}
void Sort(struct student stu[ ],int i)
{int j;
float a;
for (i=0;i<N;i++)
{for (j=0;j<5;j++)
{a=0;
a+=stu[i].s[j];
stu[i].sum=a;
print(stu,i);
printf("%8.1f\n",stu[i].sum);
}
}
for (i=0;i<N;i++)
{for (j=0;j<N+1;j++)
{if (stu[i].sum>stu[j].sum)
{temp=stu[i];
stu[i]=stu[j];
stu[j]=temp;
}
}
print(stu,i);
printf("%8.1f\n",stu[i].sum);
}
printf("please wait input any key continue");
getch();
}
void Statistics(struct student stu[ ],int i)
{int j,m=0,b=0;
for (i=0;i<3;i++)
for (j=0;j<5;j++)
{if (stu[i].s[j]<60)
{ m++;
printf("||number||name||\n");
printf("||%ld||%s||\n",stu[i].number,stu[i].name);
}
}
printf("the student don't pass exam have:%d\n",m);
for (i=0;i<3;i++)
for (j=0;j<5;j++)
{ if (stu[i].s[j]>80)
{b++;
printf("||number||name||\n");
printf("||%ld||%s||\n",stu[i].number,stu[i].name);
}
}
printf("the student pass exam have:%d\n",b);
}
main()
{ int select,i=0;
float k;
do
{
printf("\t\t\t***--------------------------------------------***\t\t\t\n");
printf("\t\t\t*** ***\t\t\t\n");
printf("\t\t\t*** Welcome to The Student's Mangement System ***\t\t\t\n");
printf("\t\t\t*** ***\t\t\t\n");
printf("\t\t\t***--------------------------------------------***\t\t\t\n");
printf("\t\t\t*** 1.Input the student's date ***\t\t\t\n");
printf("\t\t\t*** 2.Add the student's date ***\t\t\t\n");
printf("\t\t\t*** 3.Delete the student's date ***\t\t\t\n");
printf("\t\t\t*** 4.Change the student's date ***\t\t\t\n");
printf("\t\t\t*** 5.Inquire the student's date ***\t\t\t\n");
printf("\t\t\t*** 6.Sort the student's date ***\t\t\t\n");
printf("\t\t\t*** 7.Statistics the student's date ***\t\t\t\n");
printf("\t\t\t*** 0.Escape the student's system ***\t\t\t\n");
printf("Please input select=:\n");
scanf("%d",&select);
switch (select)
{ case 1:Input(stu,i);break;
case 2:Add(stu,i);break;
case 3:Delete(stu,i);break;
case 4:Change(stu,i);break;
case 5:Inquire(stu,i);break;
case 6:Sort(stu,i);break;
case 7:Statistics(stu,i);break;
default:printf("It's wrong");break;
}
}while(select!=0);
}