#include
#define MaxSize 50
struct student{
int num;
char name[10];
int computer,english,math;
double average;
};
int Count=0;
void new_student(struct student students[]);
void output_student(struct student students[]);
void monfig_student(struct student students[]);
void search_student(struct student students[],int num);
void average_student(struct student students[]);
int main(void)
{
int choice,num;
struct student students[MaxSize];
do{
printf("choice: 1:new 2:search 3: monfig 4:output :exit
");
scanf("%d",&choice);
switch(choice){
case 1: new_student(students); break;
case 2: printf("please input the student's number:");
scanf("%d",&num);
search_student(students,num);
break;
case 3:monfig_student(students);break;
case 4:output_student(students);break;
case 0:break;
}
}while(choice!=0);
printf("END!
");
return 0;
}
void new_student(struct student students[])
{
struct student s;
if (Count==MaxSize){
printf("the arry is full!
");
return;
}
printf("Imput num,name,math score,english score, computer score:");
scanf("%d %s %d %d %d",&s.num,s.name,&s.math,&s.english,&s.computer);
s.average=(s.math+s.english+s.computer)/3.0;
students[Count]=s;
Count++;
}
void search_student(struct student students[],int num)
{
int i;int flag=0;
if(Count==0){
printf("Count of students is zero!
");
return;
}
for(i=0;i",students[i].num,students[i].name,students[i].math,students[i].english,students[i].computer,students[i].average);
}
else
printf("Not Found!");
}
void monfig_student(struct