|
发表于 2015-3-7 20:16:46
|
显示全部楼层
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define n 10
- #define m 500
- #define w 500
- #define q 1000
- struct record
- {
- char team[10];
- int school1;
- int school2;
- char sporter[10];
- int sex;
- int rank1;
- int sere1;
- int spo1;
- char sp1[10];
- int rank2;
- int sere2;
- int spo2;
- char sp2[10];
- }re[q];
- struct student
- {
- char name[10];
- int sex;
- char school[10];
- int first;
- int second;
- int third;
- int shu;
- }stu[q];
- struct school5
- {
- char name[10];
- char n1[10];
- char n2[10];
- char n3[10];
- char school[10];
- int tu;
- int ju;
- }sch5[n];
- struct fen
- {
- int sc;
- char sch[10];
- int man;
- int woman;
- int team;
- int cv1;
- int cv2;
- }fe[n];
- void score()
- {
- extern void sw();
- struct fen fe[n];
- struct record re[q];
- int u,e,z,v;
- int a1,a2,a3;
- char pp[10];
- fe->cv1 = 0;
- fe->cv2 = 0;
- printf("\n********************************************************\n");
- if (fe->cv1 != 0||fe->cv2 != 0)
- {
- for (e = 1;e < n+1;e++)
- {
- fe[e].man = 0;
- fe[e].woman = 0;
- for (u = 0;u < fe->cv2;u++)
- {
- if (re[u].school2 == e)
- {
- if (re[u].sex == 1)
- {
- fe[e].man += re[u].sere2;
- }
- else
- {
- fe[e].woman += re[u].sere2;
- }
- }
- }
- }
- for (e = 1;e < n+1;e++)
- {
- fe[e].team = 0;
- for (u = 0;u < fe->cv1;u++)
- {
- if (re[u].school1 == e)
- {
- fe[e].team += re[u].sere1;
- }
- }
- fe[e].sc = fe[e].team + fe[e].man + fe[e].woman;
-
- switch (e)
- {
- case 1: strcpy(fe[e].sch,"xiao");
- break;
- case 2: strcpy(fe[e].sch,"da");
- break;
- case 3: strcpy(fe[e].sch,"walk");
- break;
- case 4: strcpy(fe[e].sch,"shao");
- break;
- case 5: strcpy(fe[e].sch,"got");
- break;
- case 6: strcpy(fe[e].sch,"good");
- break;
- case 7: strcpy(fe[e].sch,"tree");
- break;
- case 8: strcpy(fe[e].sch,"trick");
- break;
- case 9: strcpy(fe[e].sch,"dream");
- break;
- case 10: strcpy(fe[e].sch,"back");
- break;
- }
- }
-
- for (e = 1;e < n;e++)
- {
- for (z = e+1;z < n+1;z++)
- {
- if (fe[e].sc < fe[z].sc)
- {
- v = fe[e].sc;
- fe[e].sc = fe[z].sc;
- fe[z].sc = v;
- a1 = fe[e].man;
- fe[e].man = fe[z].man;
- fe[z].man = a1;
-
- a2 = fe[e].woman;
- fe[e].woman = fe[z].woman;
- fe[z].woman = a2;
- a3 = fe[e].team;
- fe[e].team = fe[z].team;
- fe[z].team = a3;
-
- strcpy(pp,fe[e].sch);
- strcpy(fe[e].sch,fe[z].sch);
- strcpy(fe[z].sch,pp);
- }
- }
- }
- printf("\n\t名次 学校 团队 男子总成绩 女子总成绩 总成绩\n");
- for (e = 1;e <n+1;e++)
- {
- printf("\t%d %s %d ",e,fe[e].sch,fe[e].team);
- printf("%d %d %d\n",fe[e].man,fe[e].woman,fe[e].sc);
- }
- }
- else
- {
- printf("\n暂无 !\n");
- }
- printf("return !\n");
- printf("请按任意键继续……\n");
- getchar();
- }
- void show3()
- {
- printf("\n......................................................\n");
- printf("*********************各个学校的编号*********************\n");
- printf("^\t 1 - xiao 2 - da ^\n");
- printf("^\t 3 - walk 4 - shao ^\n");
- printf("^\t 5 - got 6 - good ^\n");
- printf("^\t 7 - tree 8 - trick ^\n");
- printf("^\t 9 - dream 10 - back ^\n");
- printf("--------------------------------------------------------\n");
- }
- void input()
- {
- extern void prte();
- extern void prpe();
- extern void sw();
- int g;
- printf("\n**************************************************\n");
- printf("1 - 请输入获奖团队信息\n");
- printf("2 - 请输入获奖个人信息\n");
- printf("3 - return\n");
- printf("Please input number(1~3) : ");
- scanf("%d",&g);
- switch (g)
- {
- case 1: prte();
- break;
- case 2: prpe();
- break;
- case 3: sw();
- default : printf("error !\n");
- input();
- }
- }
- void prpe(struct fen *p2)
- {
- extern void show3();
- extern void show1();
- extern void sw();
- static int fl = 0;
- int f,f1,f2,f3;
- char f4,sx;
- struct record re[q];
-
- printf("\n------------------------------------------------------\n");
- show3();
- show1();
- printf("参赛人数 : ");
- scanf("%d",&f2);
- for(f = 0;f < q;f++)
- {
- printf("参赛项目 : ");
- scanf("%d",&re[f].spo2);
- f3 = re[f].spo2;
- switch (f3)
- {
- case 1: strcpy(re[f].sp2,"run");
- break;
- case 2: strcpy(re[f].sp2,"swim");
- break;
- case 3: strcpy(re[f].sp2,"jump");
- break;
- case 4: strcpy(re[f].sp2,"football");
- break;
- case 5: strcpy(re[f].sp2,"archery");
- break;
- case 6: strcpy(re[f].sp2,"shot");
- break;
- }
- printf("\nname :");
- scanf("%s",&re[f].sporter);
- printf("\nschool name : ");
- scanf("%d",&re[f].school2);
- printf("\n性别(b-boy or g-girl) :");
- scanf("%c",&sx);
- switch (sx)
- {
- case 'b': re[f].sex = 1;
- break;
- case 'g': re[f].sex = 0;
- break;
- default : printf("\nerror ! enter b or g !\n");
- prpe();
- }
- printf("\nrank : ");
- scanf("%d",&re[f].rank2);
- f1 = re[f].rank2;
- if (f2 > 6)
- {
- switch (f1)
- {
- case 1: re[f].sere2 = 7;
- break;
- case 2: re[f].sere2 = 5;
- break;
- case 3: re[f].sere2 = 3;
- break;
- case 4: re[f].sere2 = 2;
- break;
- case 5: re[f].sere2 = 1;
- break;
- default : printf("\nerror ! input again !\n");
- prpe();
- }
- }
- else
- {
- switch (f1)
- {
- case 1: re[f].sere2 = 5;
- break;
- case 2: re[f].sere2 = 3;
- break;
- case 3: re[f].sere2 = 2;
- break;
- default : printf("\nerror ! input again !\n");
- prpe();
- }
- }
- getchar();
- printf("\n 是否继续 ! please enter y(yes) or n(no) !\n");
- f4 = getchar();
- if (f4 == 'y'||f4 == 'Y')
- {
- fl++;
- p2->cv2 = fl;
- f = q;
- prpe();
- }
- else
- {
- fl++;
- p2->cv2 = fl;
- f = q;
- sw();
-
- }
- }
- }
- void prte(struct fen *p1)
- {
- extern void show3();
- extern void show1();
- extern void sw();
- static int gl = 0;
- int g,g1,g2,g4;
- char g3;
- struct record re[q];
- printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
- show3();
- show1();
- printf("参赛队伍数 : ");
- scanf("%d",&g2);
- for(g = 0;g < q;g++)
- {
- printf("参赛项目 : ");
- scanf("%d",&re[g].spo1);
- g4 = re[g].spo1;
- switch (g4)
- {
- case 1: strcpy(re[g].sp1,"run");
- break;
- case 2: strcpy(re[g].sp1,"swim");
- break;
- case 3: strcpy(re[g].sp1,"jump");
- break;
- case 4: strcpy(re[g].sp1,"football");
- break;
- case 5: strcpy(re[g].sp1,"archery");
- break;
- case 6: strcpy(re[g].sp1,"shot");
- break;
- }
- printf("\nteam name : ");
- scanf("%s",&re[g].team);
- printf("\nschool name : ");
- scanf("%d",&re[g].school1);
- printf("\nrank : ");
- scanf("%d",&re[g].rank1);
- g1 = re[g].rank1;
- if (g2 > 6)
- {
- switch (g1)
- {
- case 1: re[g].sere1 = 14;
- break;
- case 2: re[g].sere1 = 10;
- break;
- case 3: re[g].sere1 = 6;
- break;
- case 4: re[g].sere1 = 4;
- break;
- case 5: re[g].sere1 = 2;
- break;
- default : printf("\nerror ! input again !\n");
- prte();
- }
- }
- else
- {
- switch (g1)
- {
- case 1: re[g].sere1 = 10;
- break;
- case 2: re[g].sere1 = 6;
- break;
- case 3: re[g].sere1 = 4;
- break;
- default : printf("\nerror ! input again !\n");
- prte();//参数呢?
- }
- }
- getchar();
- printf("\n 是否继续 ! please enter y(yes) or n(no) : ");
- g3 = getchar();
- if (g3 == 'y'||g3 == 'Y')
- {
- gl++;
- p1->cv1 = gl;
- g = n;
- prte();
- }
- else
- {
- gl++;
- p1->cv1 = gl;
- g = n;
- sw();
-
- }
- }
- }
- void information()
- {
- extern void inschool();
- extern void incom();
- int en;
- printf("\n**************************************************\n");
- printf(" 1 - 学校信息 2 - 比赛信息\n");
- printf(" 3 - exit\n");
- printf("----------------------------------------------------\n");
- printf("enter number(1~3) what you want : ");
- scanf("%d",&en);
- switch (en)
- {
- case 1: inschool();
- break;
- case 2: incom();
- break;
- case 3: exit(0);
- default : printf("\nerror ! enter number !\n");
- information();
- }
- }
- void inschool()
- {
- extern void show1();
- extern void sw();
- struct student stu[q];
- struct school5 sch5[n];
- int x,y;
- char insex;
- char is[10],in[10];
- int t1,t2,t3;
- char k1[10],k2[10],k3[10],k4[10],k5[10];
- int l1 = 0;
- int l2 = 0;
- show1();
- printf("\n\t\t个人\n");
- if (l1 != 0)
- {
- for (x = 0;x < l1-1;x++)
- for (y = x+1;y < l1;y++)
- {
- if (strcmp(stu[y].school,stu[y+1].school) > 0||strcmp(stu[y].school,stu[y+1].school) == 0)
- {
- if(stu[y].sex>stu[y+1].sex||stu[y].sex == stu[y+1].sex)
- {
- strcpy(is,stu[y].school);
- strcpy(stu[y].school,stu[y+1].school);
- strcpy(stu[y+1].school,is);
- insex = stu[y].sex;
- stu[y].sex = stu[y+1].sex;
- stu[y+1].sex = insex;
- strcpy(in,stu[y].name);
- strcpy(stu[y].name,stu[y+1].name);
- strcpy(stu[y+1].name,in);
- t1 = stu[y].first;
- stu[y].first = stu[y+1].first;
- stu[y+1].first = t1;
- t2 = stu[y].second;
- stu[y].second = stu[y+1].second;
- stu[y+1].second = t2;
- t3 = stu[y].third;
- stu[y].third = stu[y+1].third;
- stu[y+1].third = t3;
- }
- }
- }
-
- for (x = 0;x < l1;x++)
- {
- printf("school :%s name :%s sex :%c",stu[x].school,stu[x].name,stu[x].sex);
- printf(" first=%d second=%d third=%d\n",stu[x].first,stu[x].second,stu[x].third);
- }
- }
- else
- {
- printf("\n暂无 !\n");
- }
- printf("\n\t\t团体\n");
- if (l2 != 0)
- {
- for (x = 0;x < l2-1;x++)
- for (y = x+1;y < l2;y++)
- {
- if (strcmp(sch5[y].school,sch5[y+1].school) > 0||strcmp(sch5[y].school,sch5[y+1].school) == 0)
- {
- strcpy(k1,sch5[y].school);
- strcpy(sch5[y].school,sch5[y+1].school);
- strcpy(sch5[y+1].school,k1);
- strcpy(k2,sch5[y].name);
- strcpy(sch5[y].name,sch5[y+1].name);
- strcpy(sch5[y+1].name,k2);
- strcpy(k3,sch5[y].n1);
- strcpy(sch5[y].n1,sch5[y+1].n1);
- strcpy(sch5[y+1].n1,k3);
- strcpy(k4,sch5[y].n2);
- strcpy(sch5[y].n2,sch5[y+1].n2);
- strcpy(sch5[y+1].n2,k4);
- strcpy(k5,sch5[y].n3);
- strcpy(sch5[y].n3,sch5[y+1].n3);
- strcpy(sch5[y+1].n3,k5);
- t1 = sch5[y].tu;
- sch5[y].tu = sch5[y+1].tu;
- sch5[y+1].tu = t1;
- }
- }
- for(x = 0;x < l2;x++)
- {
- printf("school :%s team :%s sport :%d\n",sch5[x].school,sch5[x].name,sch5[x].tu);
- }
- }
- else
- {
- printf("\n暂无 !\n");
- }
- printf("\nreturn the menu !\n");
- sw();
- }
- void show1()
- {
- printf("\n-----------------------运动项目编号----------------------\n");
- printf("\n\t1 - run 2 - swim\n");
- printf("\t 3 - jump 4 - football\n");
- printf("\t 5 - archery 6 - shot\n\n");
- printf("***********************************************************\n");
- }
- void incom()
- {
- extern void show1();
- extern void sw();
- struct student stu[q];
- int x,y;
- char insex;
- char is[10],in[10];
- int t1,t2,t3;
- char k1[10],k2[10],k3[10],k4[10],k5[10];
- int o1 = 0;
- int o2 = 0;
- show1();
- printf("\n\t\t个人项目\n");
- if (o1 != 0)
- {
- for (x = 0;x < o1-1;x++)
- for (y = x+1;y < o1;y++)
- {
- if (stu[y].first>stu[y+1].first||stu[y].first == stu[y+1].first)
- {
- if(stu[y].sex>stu[y+1].sex||stu[y].sex == stu[y+1].sex)
- {
- strcpy(is,stu[y].school);
- strcpy(stu[y].school,stu[y+1].school);
- strcpy(stu[y+1].school,is);
- insex = stu[y].sex;
- stu[y].sex = stu[y+1].sex;
- stu[y+1].sex = insex;
- strcpy(in,stu[y].name);
- strcpy(stu[y].name,stu[y+1].name);
- strcpy(stu[y+1].name,in);
- t1 = stu[y].first;
- stu[y].first = stu[y+1].first;
- stu[y+1].first = t1;
- t2 = stu[y].second;
- stu[y].second = stu[y+1].second;
- stu[y+1].second = t2;
- t3 = stu[y].third;
- stu[y].third = stu[y+1].third;
- stu[y+1].third = t3;
- }
- }
- }
-
-
- for (x = 0;x < o1;x++)
- {
- printf("项目一:%d ,项目二:%d ,项目三:%d ,",stu[x].first,stu[x].second,stu[x].third);
- printf("name :%s ,school :%s\n",stu[x].name,stu[x].school);
- }
- }
- else
- {
- printf("\n暂无 !\n");
- }
- printf("\n\t\t团体项目\n");
- if (o2 != 0)
- {
- for (x = 0;x < o2-1;x++)
- for (y = x+1;y < o2;y++)
- {
- if (sch5[y].tu>sch5[y+1].tu || sch5[y].tu == sch5[y+1].tu)
- {
- strcpy(k1,sch5[y].school);
- strcpy(sch5[y].school,sch5[y+1].school);
- strcpy(sch5[y+1].school,k1);
- strcpy(k2,sch5[y].name);
- strcpy(sch5[y].name,sch5[y+1].name);
- strcpy(sch5[y+1].name,k2);
- strcpy(k3,sch5[y].n1);
- strcpy(sch5[y].n1,sch5[y+1].n1);
- strcpy(sch5[y+1].n1,k3);
- strcpy(k4,sch5[y].n2);
- strcpy(sch5[y].n2,sch5[y+1].n2);
- strcpy(sch5[y+1].n2,k4);
- strcpy(k5,sch5[y].n3);
- strcpy(sch5[y].n3,sch5[y+1].n3);
- strcpy(sch5[y+1].n3,k5);
- t1 = sch5[y].tu;
- sch5[y].tu = sch5[y+1].tu;
- sch5[y+1].tu = t1;
- }
- }
- for (x = 0;x < o2; x++)
- {
- printf("项目: %d ,name :%s ,school :%s",sch5[x].tu,sch5[x].name,sch5[x].school);
- }
- }
- else
- {
- printf("\n暂无 !\n");
- }
- printf("\nreturn the menu !\n");
- sw();
- }
- void book()
- {
- extern void book1();
- extern void book2();
- int bo;
- printf("\n 1 - 个人赛 2 - 团体赛\n");
- printf(" 3 - exit\n");
- printf("enter : ");
- scanf("%d",&bo);
- switch(bo)
- {
- case 1: book1();
- break;
- case 2: book2();
- break;
- case 3: exit(0);
- default : printf("\nerror ! 1 or 2 !\n");
- book();
- }
- }
- void book1()
- {
- extern void show();
- extern void sw();
- struct student stu[q];
- static int i = 0;
- int j,k,l;
- int t1,t2,t3;
- t1 = t2 = t3 = 0;
- printf("\n*********报名登记*********\n");
- printf("input your name : ");
- scanf("%s",&stu[i].name );
- printf("choose boy or girl (input 1-boy/2-girl) : ");
- scanf("%d",&stu[i].sex);
- printf("\ninput school name : ");
- scanf("%s",&stu[i].school );
- printf("\n每个运动员最多能参加3项 !(团体不限)\n");
- printf("`````````````````````````````````````````````````````\n\n");
- show();
- scanf("%d",&stu[i].first );
- printf("\n 1 - continue 2 - finish\n");
- printf("enter : ");
- scanf("%d",&l);
- switch (l)
- {
- case 1: printf("\n input the sport number what you want : ");
- scanf("%d",&stu[i].second );
- printf("\n 1 - continue 2 - finsh\n");
- printf("enter : ");
- scanf("%d",&l);
- switch (l)
- {
- case 1: printf("\n input the sport number waht you want : ");
- scanf("%d",&stu[i].third );
- break;
- case 2: stu[i].third = 0;
- break;
- default : break;
- }
- case 2: stu[i].second = 0;
- stu[i].third = 0;
- break;
- default : break;
- }
- for (k = 0;k <= i; k++)
- {
- j = i;
-
- if (strcmp(stu[j].school,stu[k].school) == 0)
- {
- if (stu[j].first == stu[k].first )
- {
- t1++;
- if (t1 < 5)
- {
- if(stu[j].second == stu[k].second )
- {
- t2++;
- if (t2 < 5)
- {
- if (stu[j].third == stu[k].third )
- {
- t3++;
- if (t3 < 5)
- {
- i++;
- stu->shu = i;
- printf("\nfinish\nreturn the menu !\n");
- sw();
- }
- else
- {
- printf("\nyou can not choose sport %d\n",stu[j].third );
- book1();
- }
- }
- }
- else
- {
- printf("\nyou can not choose sport %d",stu[j].second );
- book1();
- }
- }
-
- }
- else
- {
- printf("\nyou can not choose sport %d",stu[j].first );
- book1();
- }
- }
- }
-
- }
- }
- void book2()
- {
- extern void show();
- extern void sw();
- struct school5 sch5[n];
- static int t = 0;
- printf("\n************报名登记*********\n");
-
- printf("\nyour school name : ");
- scanf("%s",sch5[t].school);
- printf("\n3名队员(空格键隔开) :");
- scanf("%s %s %s",sch5[t].n1,sch5[t].n2,sch5[t].n3);
- show();
- scanf("%d",sch5[t].tu);
- printf("\nteam name : ");
- scanf("%s",sch5[t].name);
- t++;
- sch5->ju = t;
- printf("\nfinish ! return the menu !\n");
- sw();
- }
- void show()
- {
- printf("\n\t1 - run 2 - swim\n");
- printf("\t 3 - jump 4 - football\n");
- printf("\t 5 - archery 6 - shot\n\n");
- printf("***********************************************************\n");
- printf("input the sport number what you want : ");
- }
- void sw()
- {
- extern void score();
- extern void information();
- extern void book();
- extern void input();
- int number;
- printf("************ welcome to use the soprts information **********\n");
- printf("*************************** menu ****************************\n");
- printf("=============================================================\n");
- printf(" 1-score 2-competition information\n");
- printf(" 3-book 4-input\n");
- printf(" 5-exit\n");
- printf("-------------------------------------------------------------\n");
- printf("Please input number what you want(1~5): ");
- scanf("%d",&number);
- switch (number)
- {
- case 1: score();
- break;
- case 2: information();
- break;
- case 3: book();
- break;
- case 4: input();
- break;
- case 5: exit(0);
- default: printf("error !\n");
- sw();
-
- }
- }
- int main()
- {
- sw();
-
- return 0;
- }
复制代码 |
|