帮帮忙,帮我写的这个运动会管理程序修改并注释一下,后面我不大会注释,拜托!!!
#include <stdio.h>#define A 100
Int y=0,f=0,j,W,M,N,p[15],q[15];
struct student
{
char school[20];
char name[20];
char item[20];
char sex;
int position;
int mark;
}
stu[A];
struct item
{
char name[20];
char sex;
int mark;
}
it[A];
struct school
{
char name[20];
char item[20];
int mark;
}
sho[A];
main()
{
menu();
}
menu()
{
int w1,n;
do
{ put(“\t\t*****************MENU*****************”);
put(“\n\n\t\t 1.The information to writein\n”);
put(“\t\t 2.The race result records to writein\n”);
put(“\t\t 3.Search the information\n”);
put(“\t\t 4.Exit\n”);
put(“\n\t\t***************************************”);
put(“\n\nChoice you number:”);
scanf(“%d”,&n);
if(n<1||n>4){w1=1;getchar();}
else w1=0;
}while(w1==1);
switch(n)
{ case 1:establish();break;
case 2:enter();break;
case 3:search();break;
case 4:exit(0);
}
}
establish()
{ int h, r; extern N,M,W;
Y=1;
printf(“\nThe number of school attended is:”);
scanf(“%d”,&N);
printf(“\nThe number of men item is:”);
scanf(“%d”,&M);
printf(“\nT he number of women item is:”);
scanf(“%d”,&W);
printf(“\nThere are three form of marked you can choice:”);
printf(“\n\n\t1).1th—7,2th—5,3th—3,4th—2,5th—1.”);
printf(“\n\n\t2).1th—5,2th—3,3th—1.”);
printf(“\n\n\t3).define by youself.”);
loop:printf(“\n\nChoice the number(1--3):”);
scanf(“%d”,&h);
if(h>0&&h<4)
switch(h)
{ case 1: j=1: berak;
case 2:j=2;break;
case 3:define_mark();
}
else goto loop;
printf(“Success!!!\nPress any key+Enter to menu..”);
scanf(“%d”,&r);
menu();
}
enter()
{ int t, r, i=0; extern j, y;char F,M;
If (y==0)
{ printf(“Please establish system first!!\nPress any key+Enter to menu..”);
scanf(“%d”,&r);
menu();
}
do
{
printf(“\nPlease enter the student’s name:\t”);
scanf(“%s”,&stu[i].name)
printf(“\nPlease enter the student’s school:\t”);
scanf(“%s”,&stu[i].school);
printf(“\nPlease enter the student’s item:\t”);
scanf(“%s”,&stu[i].item);
loop_1: printf(“please enter the student’s sex(W or M):\t”);
scanf(“%s”,&stu[i].sex);
if(stu[i].sex!=’W’&&stu[i].sex!=’M’)goto loop_1;
printf(“\nPlease enter the student’s position:\t”);
scanf(“%d”,&stu[i].position);
mark(j,i);
loop_2:printf(“\n\nDo again?\t1).Yes\t2).No\t”);
scanf(“%d”,&t);
if(t!=2&&t!=1)goto loop_2;
if(t==2)break;
i++;
} while(t==1); f=1;
printf(“Success!!!\nPress any key+Enter to menu..”);
scanf(“%d”,&r);
menu();
}
search()
{ int e; char c; extern f;
If(f==0)
{ printf(“Please enter the data first!!\nPress any key+Enter to menu..\n”);
scanf(“%s”,&c);
menu();
}
loop:printf(“\nThe form of searching you want to choice:\n\t1).By school\n\t2).Bt item\n\t3).To menu\t”);
scanf(“%d”,&e);
switch(e)
{ case 1: search_school(); break;
case 2: search_item(); break;
case 3: menu();
}
if(e>4||e<1)goto loop;
printf(“press any key+Enter to menu..”);scanf(“%s”,&c);menu();
}
search_school()
{ int x, sum=0,w=0;
struct student s;
printf(“\nplease enter the name of the school that you want to search:”);
scanf(“%s”,&s.school);
printf_face(0;
for(x=0;x<A;x++)
if(strcmp(s.school,stu[x].school)= =0)
{ sum+=stu[x].mark;
printf(“_one(x);w=1;
}
printf_sum(sum);
if(w= =0 )
{printf9’\n\n*The name is wrong,press again!”};search_school();}
}
search_item( )
{ int x, sum=0, w=0;
struct student s;
printf(“\nplease enter the name of the item that you want to search:”);
scanf(“%s”,&s.item);
printf_face( );
for(x=0;x<A;x++)
if(strcmp(s.item,stu[x].item)= =0)
{ sum+=stu[x].mark;
printf_one(x);w=1;
}
printf_sum(sum);
if(w= =0)
{printf(“\n\n*The name is wrong, press again!”);search_item( );}
}
mark(int j, int i)
{ int g;extern p[15],q[15];
if(j= =1)
{if(stu[i].position= =1)stu[i].mark=7;
else if(stu[i].position= =2)stu[i].mark=5;
else if(stu[i].position= =3)stu[i].mark=3;
else if(stu[i].position= =4)stu[i].mark=2;
else if(stu[i].position= =5)stu[i].mark=1;
}
if(j= =2)
{ if(stu[i].position= =1)stu[i].mark=5;
else if(stu[i].position= =2)stu[i].mark=3;
else if(stu[i].position= =3)stu[i].mark=1;
}
if(j= =3)
{ for(g=0;g<15;g++)if(stu[i].position= =p[g])stu[i].mark=q[g];}
}
define_mark( )
{ static int p[15],q[15],a,b,j;
for (a=0;a<15;a++)
{printf(“\nThe position(1- -15):”);scanf9“%的”,&q[a]};
printf(“\nThe mark you want to define (Intergral):”);
scanf(“%d”,&q[a]);
loop:printf(“\nDo you want define more:\t1).Yes\t2).No”);
scanf(“%d”,&b);
. if(b= =2)break;
if(b!=1)go to loop;
}
j=3;
}
printf_one(int x)
{ printf(“\n%-20s%-20s%-20s%-5c%-9d%-5d%’,stu[x].school,stu[x].item,stu[x].sex,stu[x].position,stu[x].mark);
}
printf_sum(int sum)
{ printf(“\n\nThe sum of mark is:\t%d”,sum0;
printf(“\nThe school number is:\t%d”,N);
printf(“\nThe item number is:\t%d\n”,W+M);
}
printf_face( )
{
printf(“\n\nschool name school nam item sex position mark”);
}