有N个学校,M个男子项目和W个女子项目,记录它们的比赛得分
其中男子项目编号为1~M,女子项目为M+1~M+W;
之后输出结果..................................................................有很多错误,请大家帮忙找找
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define M 5;
#define W 5;
#define N 5;
void input ( struct S_chool *p, int xm );
void putschool ( struct S_chool *p ); /*输出一学校各个项目的得分*/
void puttotal ( struct S_chool *p ); /*输出各个学校的总成绩*/
struct S_chool
{
struct X_iangmu
{
int mingci, scores;
char name[20];}xiangmu[M+W+1];
int malescores, femalescores, total;}school[N+1];
void main()
{
int i, xm;
for( ; ; )
{
printf ("请选择你所想要的功能:\n 0:退出;1:输入数据;2:输出数据;\n");
scanf ("%d",&i);
if(0==i) break;
switch( i )
{
case 1:{
printf ("请输入该项目编号\n");
scanf ("%d",&xm);
input (school, xm);
break;
}
case 2:{
printf ("请选择你所哦想要的功能:\n1:输出一学校成绩;2:输出团体总分报表;\n");
scanf ("%d",&i);
if( 1==i )
{
putschool ( school );
}
else if( 2==i )
{
puttotal ( school );
}
else
{
printf("错误的输入\n");
break;
}
}
default:{
printf("错误的选择输入.\n");
break;
}
}
}
}
void input( struct S_chool *p, int xm )
{
int xx;
printf("请输入学校编号:\n");
scanf ("%d",&xx);
printf("请输入名次:\n");
scanf ("%d",&p[xx].xiangmu[xm].mingci);
printf("请输入该选手姓名:\n");
scanf ("%s",p[xx].xiangmu[xm].name);
printf("请输入该选手得分:\n");
scanf ("%d",&p[xx].xiangmu[xm].scores);
}
void putschool( struct S_chool *p )
{
int xx, xm;
printf("请输入所查询学校的编号:\n");
scanf("%d",&xx);
printf("该学校的成绩如下:\n\n");
for( xm=1; xm <= W+M; xm++ )
{
printf("%d %d %s %d\n\n",xm, p[xx].xiangmu[xm].mingci, p[xx].xiangmu[xm].name, p[xx].xiangmu[xm].scores);
}
}
void puttotal( struct S_chool *p )
{
int xx, xm;
printf("以下是所有学校的男团,女团和总体成绩:\n\n");
for( xx=1; xx <= N; xx++)
{
for( xm=1; xm <= M; xm++ )
p[xx].malescores+=p[xx].xiangmu[xm].scores;
for( j=M+1; j <= M+W; j++ )
p[xx].femalescores+=p[xx].miangmu[xm].scores;
p[xx].total=p[xx].malescores+p[xx].femalescores;
printf("%d %d %d",p[xx].malescores, p[xx].femalescores, p[xx].total);
}
}