#include
#include
#include
struct sport
{
char sex,athname[10];
char itemtype,itemname[10];
int itemrank,itemnum,mgrade,wgrade;
}ath[2];
struct school
{
int num;
char name[10];
struct sport ath[2];
//int score;
}sch[2];
void xuexiaochazhao()
{
int a,b,schoolnum;
printf("請輸入你要查詢的學校編號:");
scanf("%d",&schoolnum);
for(a=0;a<2;a++)
{
for(b=0;b<2;b++)
if(sch[a].num==schoolnum)
{
printf("學校編號,名稱,運動員(姓名,性別,項目類型,項目編號,項目名稱,項目得分)");
printf("\n%5d,%5s,%10s,%5c,%5c,%7d,%13s,%5d\n",
sch[a].num,sch[a].name,sch[a].ath[b].athname,sch[a].ath[b].sex,
sch[a].ath[b].itemtype,sch[a].ath[b].itemnum,sch[a].ath[b].itemname,
sch[a].ath[b].itemrank);
}
}
}
void xiangmuchazhao()
{
int a,b,itnum;
printf("請輸入你要查詢的項目編號:");
scanf("%d",&itnum);
for(a=0;a<2;a++)
{
for(b=0;b<2;b++)
{
if(ath[b].itemnum==itnum)
{
printf("學校編號,名稱,運動員(姓名,性別,項目類型,項目編號,項目名稱,項目得分)");
printf("\n%5d,%5s,%10s,%5c,%5c,%7d,%13s,%5d\n",
sch[a].num,sch[a].name,sch[a].ath[b].athname,sch[a].ath[b].sex,
sch[a].ath[b].itemtype,sch[a].ath[b].itemnum,sch[a].ath[b].itemname,
sch[a].ath[b].itemrank);
}
}
}
}
void menu()
{
void inputandrecord(),exited();
int n,i;
printf(" 運動會比賽計分系統 \n");
printf(" 1,本次運動會共有N個學校,M個男生項目,W個女生項目 \n");
printf("2,各個項目項目名次對應得分有兩種情況:a,前五名依次得分:7,5,3,2,1;b,前三名依次得分:5,3,2,\n");
printf(" 3,賽後記錄每個項目對應得分情況 \n");
printf(" 4,查找每個學校的比賽情況 \n");
printf(" 5,退出 \n");
printf(" -------------------");
printf(" -------------------\n");
for(i=0;i<2;i++)
{
scanf("%d",&n);
switch(n)
{
case 1: inputandrecord();break;
case 5: exited();break;
}
}
}
void inputandrecord()
{
int a,b,m,chazhao;
for(a=0;a<2;a++)
{
printf("\n請輸入學校信息\n");
printf("編號:");scanf("%d",&sch[a].num);
printf("名字:");scanf("%s",sch[a].name);
getchar();
for(b=0;b<2;b++)
{
printf("\n請輸入項目信息\n");
printf("類型:");scanf("%c",&sch[a].ath[b].itemtype);
printf("編號:");scanf("%d",&sch[a].ath[b].itemnum);
printf("名字:");scanf("%s",sch[a].ath[b].itemname);
getchar();
printf("\n請輸入運動員信息\n");
printf("名字:");scanf("%s",sch[a].ath[b].athname);
getchar();
printf("性別:");scanf("%c",&sch[a].ath[b].sex);
printf("名次:");scanf("%d",sch[a].ath[b].itemrank);
if(sch[a].ath[b].itemtype=='W')
{
switch(sch[a].ath[b].itemrank)
{
case 0:printf("沒有此名次;\n");break;
case 1:sch[a].ath[b].mgrade=5;printf("mgrade=5\n");break;
case 2:sch[a].ath[b].mgrade=3;printf("mgrade=3\n");break;
case 3:sch[a].ath[b].mgrade=2;printf("mgrade=2\n");break;
default:printf("不符合條件;\n");
}
}
if(sch[a].ath[b].itemtype=='M')
{
switch(sch[a].ath[b].itemrank)
{
case 0:printf("沒有此名次;\n");break;
case 1:sch[a].ath[b].wgrade=7;printf("wgrade=7\n");break;
case 2:sch[a].ath[b].wgrade=5;printf("wgrade=5\n");break;
case 3:sch[a].ath[b].wgrade=3;printf("wgrade=3\n");break;
case 4:sch[a].ath[b].wgrade=2;printf("wgrade=2\n");break;
case 5:sch[a].ath[b].wgrade=1;printf("wgrade=1\n");break;
default:printf("不符合條件;\n");
}
}
}
}
for(a=0;a<2;a++)
{
printf("====學校編號:");
printf("%d\n",sch[a].num);
for(b=0;b<2;b++)
{
printf("ath[a]:%s-%s-%c-%c-%d-%s-%d\n\n",sch[a].name,sch[a].ath[b].athname,
sch[a].ath[b].sex,sch[a].ath[b].itemtype,sch[a].ath[b].itemnum,
sch[a].ath[b].itemname,sch[a].ath[b].itemrank);
}
}
printf("*******************\n\n");
for(m=0;m<4;m++)
{
printf("按學校查找請輸入1,按項目查找請輸入2: ");
scanf(" %d",&chazhao);
if(chazhao==1)
xuexiaochazhao();
if(chazhao==2)
xiangmuchazhao();
}
}
void exited()
{
printf(" -------------------\n");
printf(" -------------------\n");
printf("感謝老師驗收\n");
printf(" -------------------\n");
printf(" -------------------");
}
void main()
{
system("color f5");
menu();
}
你壓根兒都沒有輸入,怎麼輸出呢?