用C语言编一个模拟国际羽毛球比赛记分系统的程序

来源:百度知道 编辑:UC知道 时间:2024/05/21 11:46:06
先输入两名运动员姓名,循环每次延迟约一秒钟后,随机决定甲方或乙方得分,在屏幕同一位置上刷新记分。比赛采用21分制,但20:20之后,一方要净胜2分比赛才能结束。

要求:
1.要有清屏;
2.要有定点显示,尽量安排在屏幕合适位置作输入输出;
3.数据输入时要有输入提示;
4.数据输入完成后应重新清屏,然后输出得分;
5.输出结果按类似如下格式显示在屏幕中央:
LinDan ChenHong
5 6
6.最终结果显示后要有暂停,按回车后才终止程序运行;
7.屏幕按每行40列模式显示。

#include "stdio.h"
#include <math.h>

struct copetitont
{ char name[10];
int score ;
} a[2];

int mi=0,c,ma=0;

max(int x, int y)
{
return(x>y?x:y);
}

min(int x, int y)
{
return(x>y?y:x);
}

void yundong()
{
{ sleep(1);
clrscr();
c=rand()%2;
if( c==1 ) a[1].score++;
else a[0].score++;

ma=max(a[0].score,a[1].score);
gotoxy(25,10);
printf(" %s 's score:%d \n", a[0].name,a[0].score);
gotoxy(25,13);
printf(" %s 's score:%d \n", a[1].name,a[1].score);
}
}
main()
{ int i ,t ;
clrscr();
for(i=0;i<2;i++)
{
printf("please input the %d Athletes's name:\n",i);
gets(a[i].name);
a[i].score=0;
}

whi