编写学校运动会管理系统所遇到的大问题
#include <stdio.h>#include <stdlib.h>
#include <string.h>
#define n 10
#define m 500
#define w 500
#define q 1000
struct record
{菜鸟求助。。。(这程序本来就菜了,请大神们耐心看,我都是用笨方法编写的,敬请原谅!)
问题概述:
1.用不了信息查询的功能
2.输入的信息(如:报名信息),不能调用,并以查询方式输出,也可以说是不能储存数据
3.容易发生死循环
4.我完全跪了………Orz,不知怎么做啊!
(在C知识范围内请教,不介意高深方法,菜鸟我还在学)
也可以不在我所编写基础上修改,这是学生作业,我不会抄袭大神们的,我只想看看您们怎么编写的;
这代码不完整吧?!{:7_138:} ~风介~ 发表于 2015-3-6 21:13
这代码不完整吧?!
不会吧!我全部复制过去的。(按常理讲,的确不完整,有好几个功能都用不了,真心不知怎么办,您能帮帮忙吗?菜鸟我都跪了好几天了………Orz):cry ~风介~ 发表于 2015-3-6 21:13
这代码不完整吧?!
咦。这代码怎么缺少得好恐怖,我错了,我试试在弄上去 C盲夫 发表于 2015-3-7 10:44
咦。这代码怎么缺少得好恐怖,我错了,我试试在弄上去
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define n 10
#define m 500
#define w 500
#define q 1000
struct record
{
charteam;
int school1;
int school2;
charsporter;
int sex;
int rank1;
int sere1;
int spo1;
charsp1;
int rank2;
int sere2;
int spo2;
charsp2;
}re;
struct student
{
charname;
int sex;
charschool;
int first;
int second;
int third;
int shu;
}stu;
struct school5
{
char name;
char n1;
char n2;
char n3;
char school;
inttu;
intju;
}sch5;
struct fen
{
int sc;
charsch;
int man;
int woman;
int team;
int cv1;
int cv2;
}fe;
第一小部分 C盲夫 发表于 2015-3-7 10:46
第一小部分
void score()
{
extern void sw();
struct fen fe;
struct record re;
intu,e,z,v;
inta1,a2,a3;
char pp;
fe->cv1 = 0;
fe->cv2 = 0;
printf("\n********************************************************\n");
if (fe->cv1 != 0||fe->cv2 != 0)
{
for (e = 1;e < n+1;e++)
{
fe.man = 0;
fe.woman = 0;
for (u = 0;u < fe->cv2;u++)
{
if (re.school2 == e)
{
if (re.sex == 1)
{
fe.man += re.sere2;
}
else
{
fe.woman += re.sere2;
}
}
}
}
for (e = 1;e < n+1;e++)
{
fe.team = 0;
for (u = 0;u < fe->cv1;u++)
{
if (re.school1 == e)
{
fe.team += re.sere1;
}
}
fe.sc = fe.team + fe.man + fe.woman;
switch (e)
{
case 1: strcpy(fe.sch,"xiao");
break;
case 2: strcpy(fe.sch,"da");
break;
case 3: strcpy(fe.sch,"walk");
break;
case 4: strcpy(fe.sch,"shao");
break;
case 5: strcpy(fe.sch,"got");
break;
case 6: strcpy(fe.sch,"good");
break;
case 7: strcpy(fe.sch,"tree");
break;
case 8: strcpy(fe.sch,"trick");
break;
case 9: strcpy(fe.sch,"dream");
break;
case 10: strcpy(fe.sch,"back");
break;
}
}
for (e = 1;e < n;e++)
{
for (z = e+1;z < n+1;z++)
{
if (fe.sc < fe.sc)
{
v = fe.sc;
fe.sc = fe.sc;
fe.sc = v;
a1 = fe.man;
fe.man = fe.man;
fe.man = a1;
a2 = fe.woman;
fe.woman = fe.woman;
fe.woman = a2;
a3 = fe.team;
fe.team = fe.team;
fe.team = a3;
strcpy(pp,fe.sch);
strcpy(fe.sch,fe.sch);
strcpy(fe.sch,pp);
}
}
}
printf("\n\t名次 学校 团队 男子总成绩 女子总成绩 总成绩\n");
for (e = 1;e <n+1;e++)
{
printf("\t%d %s %d ",e,fe.sch,fe.team);
printf("%d %d %d\n",fe.man,fe.woman,fe.sc);
}
}
else
{
printf("\n暂无 !\n");
}
printf("return !\n");
printf("请按任意键继续……\n");
getchar();
} C盲夫 发表于 2015-3-7 10:47
void show3()
{
printf("\n......................................................\n");
printf("*********************各个学校的编号*********************\n");
printf("^\t1 - xiao 2 - da ^\n");
printf("^\t3 - walk 4 - shao ^\n");
printf("^\t5 - got 6 - good ^\n");
printf("^\t7 - tree 8 - trick^\n");
printf("^\t9 - 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;
intf,f1,f2,f3;
char f4,sx;
struct record re;
printf("\n------------------------------------------------------\n");
show3();
show1();
printf("参赛人数 : ");
scanf("%d",&f2);
for(f = 0;f < q;f++)
{
printf("参赛项目 : ");
scanf("%d",&re.spo2);
f3 = re.spo2;
switch (f3)
{
case 1: strcpy(re.sp2,"run");
break;
case 2: strcpy(re.sp2,"swim");
break;
case 3: strcpy(re.sp2,"jump");
break;
case 4: strcpy(re.sp2,"football");
break;
case 5: strcpy(re.sp2,"archery");
break;
case 6: strcpy(re.sp2,"shot");
break;
}
printf("\nname :");
scanf("%s",&re.sporter);
printf("\nschool name : ");
scanf("%d",&re.school2);
printf("\n性别(b-boy or g-girl) :");
scanf("%c",&sx);
switch (sx)
{
case 'b': re.sex = 1;
break;
case 'g': re.sex = 0;
break;
default : printf("\nerror ! enter b or g !\n");
prpe();
}
printf("\nrank : ");
scanf("%d",&re.rank2);
f1 = re.rank2;
if (f2 > 6)
{
switch (f1)
{
case 1: re.sere2 = 7;
break;
case 2: re.sere2 = 5;
break;
case 3: re.sere2 = 3;
break;
case 4: re.sere2 = 2;
break;
case 5: re.sere2 = 1;
break;
default : printf("\nerror ! input again !\n");
prpe();
}
}
else
{
switch (f1)
{
case 1: re.sere2 = 5;
break;
case 2: re.sere2 = 3;
break;
case 3: re.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;
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
show3();
show1();
printf("参赛队伍数 : ");
scanf("%d",&g2);
for(g = 0;g < q;g++)
{
printf("参赛项目 : ");
scanf("%d",&re.spo1);
g4 = re.spo1;
switch (g4)
{
case 1: strcpy(re.sp1,"run");
break;
case 2: strcpy(re.sp1,"swim");
break;
case 3: strcpy(re.sp1,"jump");
break;
case 4: strcpy(re.sp1,"football");
break;
case 5: strcpy(re.sp1,"archery");
break;
case 6: strcpy(re.sp1,"shot");
break;
}
printf("\nteam name : ");
scanf("%s",&re.team);
printf("\nschool name : ");
scanf("%d",&re.school1);
printf("\nrank : ");
scanf("%d",&re.rank1);
g1 = re.rank1;
if (g2 > 6)
{
switch (g1)
{
case 1: re.sere1 = 14;
break;
case 2: re.sere1 = 10;
break;
case 3: re.sere1 = 6;
break;
case 4: re.sere1 = 4;
break;
case 5: re.sere1 = 2;
break;
default : printf("\nerror ! input again !\n");
prte();
}
}
else
{
switch (g1)
{
case 1: re.sere1 = 10;
break;
case 2: re.sere1 = 6;
break;
case 3: re.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();
}
}
} C盲夫 发表于 2015-3-7 10:48
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;
struct school5 sch5;
intx,y;
char insex;
char is,in;
intt1,t2,t3;
char k1,k2,k3,k4,k5;
intl1 = 0;
intl2 = 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.school,stu.school) > 0||strcmp(stu.school,stu.school) == 0)
{
if(stu.sex>stu.sex||stu.sex == stu.sex)
{
strcpy(is,stu.school);
strcpy(stu.school,stu.school);
strcpy(stu.school,is);
insex = stu.sex;
stu.sex = stu.sex;
stu.sex = insex;
strcpy(in,stu.name);
strcpy(stu.name,stu.name);
strcpy(stu.name,in);
t1 = stu.first;
stu.first = stu.first;
stu.first = t1;
t2 = stu.second;
stu.second = stu.second;
stu.second = t2;
t3 = stu.third;
stu.third = stu.third;
stu.third = t3;
}
}
}
for (x = 0;x < l1;x++)
{
printf("school :%s name :%s sex :%c",stu.school,stu.name,stu.sex);
printf(" first=%d second=%d third=%d\n",stu.first,stu.second,stu.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.school,sch5.school) > 0||strcmp(sch5.school,sch5.school) == 0)
{
strcpy(k1,sch5.school);
strcpy(sch5.school,sch5.school);
strcpy(sch5.school,k1);
strcpy(k2,sch5.name);
strcpy(sch5.name,sch5.name);
strcpy(sch5.name,k2);
strcpy(k3,sch5.n1);
strcpy(sch5.n1,sch5.n1);
strcpy(sch5.n1,k3);
strcpy(k4,sch5.n2);
strcpy(sch5.n2,sch5.n2);
strcpy(sch5.n2,k4);
strcpy(k5,sch5.n3);
strcpy(sch5.n3,sch5.n3);
strcpy(sch5.n3,k5);
t1 = sch5.tu;
sch5.tu = sch5.tu;
sch5.tu = t1;
}
}
for(x = 0;x < l2;x++)
{
printf("school :%s team :%s sport :%d\n",sch5.school,sch5.name,sch5.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;
intx,y;
char insex;
char is,in;
intt1,t2,t3;
char k1,k2,k3,k4,k5;
into1 = 0;
into2 = 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.first>stu.first||stu.first == stu.first)
{
if(stu.sex>stu.sex||stu.sex == stu.sex)
{
strcpy(is,stu.school);
strcpy(stu.school,stu.school);
strcpy(stu.school,is);
insex = stu.sex;
stu.sex = stu.sex;
stu.sex = insex;
strcpy(in,stu.name);
strcpy(stu.name,stu.name);
strcpy(stu.name,in);
t1 = stu.first;
stu.first = stu.first;
stu.first = t1;
t2 = stu.second;
stu.second = stu.second;
stu.second = t2;
t3 = stu.third;
stu.third = stu.third;
stu.third = t3;
}
}
}
for (x = 0;x < o1;x++)
{
printf("项目一:%d ,项目二:%d ,项目三:%d ,",stu.first,stu.second,stu.third);
printf("name :%s ,school :%s\n",stu.name,stu.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.tu>sch5.tu || sch5.tu == sch5.tu)
{
strcpy(k1,sch5.school);
strcpy(sch5.school,sch5.school);
strcpy(sch5.school,k1);
strcpy(k2,sch5.name);
strcpy(sch5.name,sch5.name);
strcpy(sch5.name,k2);
strcpy(k3,sch5.n1);
strcpy(sch5.n1,sch5.n1);
strcpy(sch5.n1,k3);
strcpy(k4,sch5.n2);
strcpy(sch5.n2,sch5.n2);
strcpy(sch5.n2,k4);
strcpy(k5,sch5.n3);
strcpy(sch5.n3,sch5.n3);
strcpy(sch5.n3,k5);
t1 = sch5.tu;
sch5.tu = sch5.tu;
sch5.tu = t1;
}
}
for (x = 0;x < o2; x++)
{
printf("项目: %d ,name :%s ,school :%s",sch5.tu,sch5.name,sch5.school);
}
}
else
{
printf("\n暂无 !\n");
}
printf("\nreturn the menu !\n");
sw();
} C盲夫 发表于 2015-3-7 10:49
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;
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.name );
printf("choose boy or girl (input 1-boy/2-girl) : ");
scanf("%d",&stu.sex);
printf("\ninput school name : ");
scanf("%s",&stu.school );
printf("\n每个运动员最多能参加3项 !(团体不限)\n");
printf("`````````````````````````````````````````````````````\n\n");
show();
scanf("%d",&stu.first );
printf("\n1 - 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.second );
printf("\n1 - 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.third );
break;
case 2:stu.third = 0;
break;
default :break;
}
case 2:stu.second = 0;
stu.third = 0;
break;
default :break;
}
for (k = 0;k <= i; k++)
{
j = i;
if (strcmp(stu.school,stu.school) == 0)
{
if (stu.first == stu.first )
{
t1++;
if (t1 < 5)
{
if(stu.second == stu.second )
{
t2++;
if (t2 < 5)
{
if (stu.third == stu.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.third );
book1();
}
}
}
else
{
printf("\nyou can not choose sport %d",stu.second );
book1();
}
}
}
else
{
printf("\nyou can not choose sport %d",stu.first );
book1();
}
}
}
}
}
void book2()
{
extern void show();
extern void sw();
struct school5 sch5;
static int t = 0;
printf("\n************报名登记*********\n");
printf("\nyour school name : ");
scanf("%s",sch5.school);
printf("\n3名队员(空格键隔开) :");
scanf("%s %s %s",sch5.n1,sch5.n2,sch5.n3);
show();
scanf("%d",sch5.tu);
printf("\nteam name : ");
scanf("%s",sch5.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();
}
}
void main()
{
sw();
} ~风介~ 发表于 2015-3-6 21:13
这代码不完整吧?!
大哥,能帮我看看吗。。我都弄上去了。。 把 代码打包成附件! ~风介~ 发表于 2015-3-7 15:50
把 代码打包成附件!
http://pan.baidu.com/s/1jG68HOM
不会弄附件,所以弄成了链接(敬请原谅 !) C盲夫 发表于 2015-3-7 19:16
http://pan.baidu.com/s/1jG68HOM
不会弄附件,所以弄成了链接(敬请原谅 !)
我看看哈~ ~风介~ 发表于 2015-3-7 19:58
我看看哈~
好的!谢谢,大哥 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define n 10
#define m 500
#define w 500
#define q 1000
struct record
{
charteam;
int school1;
int school2;
charsporter;
int sex;
int rank1;
int sere1;
int spo1;
charsp1;
int rank2;
int sere2;
int spo2;
charsp2;
}re;
struct student
{
charname;
int sex;
charschool;
int first;
int second;
int third;
int shu;
}stu;
struct school5
{
char name;
char n1;
char n2;
char n3;
char school;
inttu;
intju;
}sch5;
struct fen
{
int sc;
charsch;
int man;
int woman;
int team;
int cv1;
int cv2;
}fe;
void score()
{
extern void sw();
struct fen fe;
struct record re;
intu,e,z,v;
inta1,a2,a3;
char pp;
fe->cv1 = 0;
fe->cv2 = 0;
printf("\n********************************************************\n");
if (fe->cv1 != 0||fe->cv2 != 0)
{
for (e = 1;e < n+1;e++)
{
fe.man = 0;
fe.woman = 0;
for (u = 0;u < fe->cv2;u++)
{
if (re.school2 == e)
{
if (re.sex == 1)
{
fe.man += re.sere2;
}
else
{
fe.woman += re.sere2;
}
}
}
}
for (e = 1;e < n+1;e++)
{
fe.team = 0;
for (u = 0;u < fe->cv1;u++)
{
if (re.school1 == e)
{
fe.team += re.sere1;
}
}
fe.sc = fe.team + fe.man + fe.woman;
switch (e)
{
case 1: strcpy(fe.sch,"xiao");
break;
case 2: strcpy(fe.sch,"da");
break;
case 3: strcpy(fe.sch,"walk");
break;
case 4: strcpy(fe.sch,"shao");
break;
case 5: strcpy(fe.sch,"got");
break;
case 6: strcpy(fe.sch,"good");
break;
case 7: strcpy(fe.sch,"tree");
break;
case 8: strcpy(fe.sch,"trick");
break;
case 9: strcpy(fe.sch,"dream");
break;
case 10: strcpy(fe.sch,"back");
break;
}
}
for (e = 1;e < n;e++)
{
for (z = e+1;z < n+1;z++)
{
if (fe.sc < fe.sc)
{
v = fe.sc;
fe.sc = fe.sc;
fe.sc = v;
a1 = fe.man;
fe.man = fe.man;
fe.man = a1;
a2 = fe.woman;
fe.woman = fe.woman;
fe.woman = a2;
a3 = fe.team;
fe.team = fe.team;
fe.team = a3;
strcpy(pp,fe.sch);
strcpy(fe.sch,fe.sch);
strcpy(fe.sch,pp);
}
}
}
printf("\n\t名次 学校 团队 男子总成绩 女子总成绩 总成绩\n");
for (e = 1;e <n+1;e++)
{
printf("\t%d %s %d ",e,fe.sch,fe.team);
printf("%d %d %d\n",fe.man,fe.woman,fe.sc);
}
}
else
{
printf("\n暂无 !\n");
}
printf("return !\n");
printf("请按任意键继续……\n");
getchar();
}
void show3()
{
printf("\n......................................................\n");
printf("*********************各个学校的编号*********************\n");
printf("^\t1 - xiao 2 - da ^\n");
printf("^\t3 - walk 4 - shao ^\n");
printf("^\t5 - got 6 - good ^\n");
printf("^\t7 - tree 8 - trick^\n");
printf("^\t9 - 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;
intf,f1,f2,f3;
char f4,sx;
struct record re;
printf("\n------------------------------------------------------\n");
show3();
show1();
printf("参赛人数 : ");
scanf("%d",&f2);
for(f = 0;f < q;f++)
{
printf("参赛项目 : ");
scanf("%d",&re.spo2);
f3 = re.spo2;
switch (f3)
{
case 1: strcpy(re.sp2,"run");
break;
case 2: strcpy(re.sp2,"swim");
break;
case 3: strcpy(re.sp2,"jump");
break;
case 4: strcpy(re.sp2,"football");
break;
case 5: strcpy(re.sp2,"archery");
break;
case 6: strcpy(re.sp2,"shot");
break;
}
printf("\nname :");
scanf("%s",&re.sporter);
printf("\nschool name : ");
scanf("%d",&re.school2);
printf("\n性别(b-boy or g-girl) :");
scanf("%c",&sx);
switch (sx)
{
case 'b': re.sex = 1;
break;
case 'g': re.sex = 0;
break;
default : printf("\nerror ! enter b or g !\n");
prpe();
}
printf("\nrank : ");
scanf("%d",&re.rank2);
f1 = re.rank2;
if (f2 > 6)
{
switch (f1)
{
case 1: re.sere2 = 7;
break;
case 2: re.sere2 = 5;
break;
case 3: re.sere2 = 3;
break;
case 4: re.sere2 = 2;
break;
case 5: re.sere2 = 1;
break;
default : printf("\nerror ! input again !\n");
prpe();
}
}
else
{
switch (f1)
{
case 1: re.sere2 = 5;
break;
case 2: re.sere2 = 3;
break;
case 3: re.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;
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
show3();
show1();
printf("参赛队伍数 : ");
scanf("%d",&g2);
for(g = 0;g < q;g++)
{
printf("参赛项目 : ");
scanf("%d",&re.spo1);
g4 = re.spo1;
switch (g4)
{
case 1: strcpy(re.sp1,"run");
break;
case 2: strcpy(re.sp1,"swim");
break;
case 3: strcpy(re.sp1,"jump");
break;
case 4: strcpy(re.sp1,"football");
break;
case 5: strcpy(re.sp1,"archery");
break;
case 6: strcpy(re.sp1,"shot");
break;
}
printf("\nteam name : ");
scanf("%s",&re.team);
printf("\nschool name : ");
scanf("%d",&re.school1);
printf("\nrank : ");
scanf("%d",&re.rank1);
g1 = re.rank1;
if (g2 > 6)
{
switch (g1)
{
case 1: re.sere1 = 14;
break;
case 2: re.sere1 = 10;
break;
case 3: re.sere1 = 6;
break;
case 4: re.sere1 = 4;
break;
case 5: re.sere1 = 2;
break;
default : printf("\nerror ! input again !\n");
prte();
}
}
else
{
switch (g1)
{
case 1: re.sere1 = 10;
break;
case 2: re.sere1 = 6;
break;
case 3: re.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;
struct school5 sch5;
intx,y;
char insex;
char is,in;
intt1,t2,t3;
char k1,k2,k3,k4,k5;
intl1 = 0;
intl2 = 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.school,stu.school) > 0||strcmp(stu.school,stu.school) == 0)
{
if(stu.sex>stu.sex||stu.sex == stu.sex)
{
strcpy(is,stu.school);
strcpy(stu.school,stu.school);
strcpy(stu.school,is);
insex = stu.sex;
stu.sex = stu.sex;
stu.sex = insex;
strcpy(in,stu.name);
strcpy(stu.name,stu.name);
strcpy(stu.name,in);
t1 = stu.first;
stu.first = stu.first;
stu.first = t1;
t2 = stu.second;
stu.second = stu.second;
stu.second = t2;
t3 = stu.third;
stu.third = stu.third;
stu.third = t3;
}
}
}
for (x = 0;x < l1;x++)
{
printf("school :%s name :%s sex :%c",stu.school,stu.name,stu.sex);
printf(" first=%d second=%d third=%d\n",stu.first,stu.second,stu.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.school,sch5.school) > 0||strcmp(sch5.school,sch5.school) == 0)
{
strcpy(k1,sch5.school);
strcpy(sch5.school,sch5.school);
strcpy(sch5.school,k1);
strcpy(k2,sch5.name);
strcpy(sch5.name,sch5.name);
strcpy(sch5.name,k2);
strcpy(k3,sch5.n1);
strcpy(sch5.n1,sch5.n1);
strcpy(sch5.n1,k3);
strcpy(k4,sch5.n2);
strcpy(sch5.n2,sch5.n2);
strcpy(sch5.n2,k4);
strcpy(k5,sch5.n3);
strcpy(sch5.n3,sch5.n3);
strcpy(sch5.n3,k5);
t1 = sch5.tu;
sch5.tu = sch5.tu;
sch5.tu = t1;
}
}
for(x = 0;x < l2;x++)
{
printf("school :%s team :%s sport :%d\n",sch5.school,sch5.name,sch5.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;
intx,y;
char insex;
char is,in;
intt1,t2,t3;
char k1,k2,k3,k4,k5;
into1 = 0;
into2 = 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.first>stu.first||stu.first == stu.first)
{
if(stu.sex>stu.sex||stu.sex == stu.sex)
{
strcpy(is,stu.school);
strcpy(stu.school,stu.school);
strcpy(stu.school,is);
insex = stu.sex;
stu.sex = stu.sex;
stu.sex = insex;
strcpy(in,stu.name);
strcpy(stu.name,stu.name);
strcpy(stu.name,in);
t1 = stu.first;
stu.first = stu.first;
stu.first = t1;
t2 = stu.second;
stu.second = stu.second;
stu.second = t2;
t3 = stu.third;
stu.third = stu.third;
stu.third = t3;
}
}
}
for (x = 0;x < o1;x++)
{
printf("项目一:%d ,项目二:%d ,项目三:%d ,",stu.first,stu.second,stu.third);
printf("name :%s ,school :%s\n",stu.name,stu.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.tu>sch5.tu || sch5.tu == sch5.tu)
{
strcpy(k1,sch5.school);
strcpy(sch5.school,sch5.school);
strcpy(sch5.school,k1);
strcpy(k2,sch5.name);
strcpy(sch5.name,sch5.name);
strcpy(sch5.name,k2);
strcpy(k3,sch5.n1);
strcpy(sch5.n1,sch5.n1);
strcpy(sch5.n1,k3);
strcpy(k4,sch5.n2);
strcpy(sch5.n2,sch5.n2);
strcpy(sch5.n2,k4);
strcpy(k5,sch5.n3);
strcpy(sch5.n3,sch5.n3);
strcpy(sch5.n3,k5);
t1 = sch5.tu;
sch5.tu = sch5.tu;
sch5.tu = t1;
}
}
for (x = 0;x < o2; x++)
{
printf("项目: %d ,name :%s ,school :%s",sch5.tu,sch5.name,sch5.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;
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.name );
printf("choose boy or girl (input 1-boy/2-girl) : ");
scanf("%d",&stu.sex);
printf("\ninput school name : ");
scanf("%s",&stu.school );
printf("\n每个运动员最多能参加3项 !(团体不限)\n");
printf("`````````````````````````````````````````````````````\n\n");
show();
scanf("%d",&stu.first );
printf("\n1 - 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.second );
printf("\n1 - 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.third );
break;
case 2:stu.third = 0;
break;
default :break;
}
case 2:stu.second = 0;
stu.third = 0;
break;
default :break;
}
for (k = 0;k <= i; k++)
{
j = i;
if (strcmp(stu.school,stu.school) == 0)
{
if (stu.first == stu.first )
{
t1++;
if (t1 < 5)
{
if(stu.second == stu.second )
{
t2++;
if (t2 < 5)
{
if (stu.third == stu.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.third );
book1();
}
}
}
else
{
printf("\nyou can not choose sport %d",stu.second );
book1();
}
}
}
else
{
printf("\nyou can not choose sport %d",stu.first );
book1();
}
}
}
}
}
void book2()
{
extern void show();
extern void sw();
struct school5 sch5;
static int t = 0;
printf("\n************报名登记*********\n");
printf("\nyour school name : ");
scanf("%s",sch5.school);
printf("\n3名队员(空格键隔开) :");
scanf("%s %s %s",sch5.n1,sch5.n2,sch5.n3);
show();
scanf("%d",sch5.tu);
printf("\nteam name : ");
scanf("%s",sch5.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;
} 运行通不过!提示第415行函数缺少参数... ~风介~ 发表于 2015-3-7 20:18
运行通不过!提示第415行函数缺少参数...
我忘记删了括号里面的参数“225 void prpe (struct fen *p1)""339 void prpe (struct fen *p2)"
~风介~ 发表于 2015-3-7 20:18
运行通不过!提示第415行函数缺少参数...
我想弄成计算人数的,以便其他输出函数调用方便,结果不会做………… C盲夫 发表于 2015-3-7 20:40
我忘记删了括号里面的参数“225 void prpe (struct fen *p1)""339 void prpe (struct fen *p2)"
先把你的代码调试没报错好不好?{:7_140:} ~风介~ 发表于 2015-3-7 20:48
先把你的代码调试没报错好不好?
323 ”p2“改成"fe"
330 "p2"改成"fe"
424 "p1"改成"fe"
430 "p1"改成”fe“
这下可运行了,不好意思,大哥
页:
[1]
2