在网球比赛中,一方先胜6局为胜一盘,双方各得5局时,一方必须净胜()局才算胜一盘。
必须净胜2局才算胜一盘
C++/C语言 简单的网球记分程序
试试看看,由于本人太了解网球的规则。
换发球,是按照一人一次写的。不知道对不对。
如果有问题,请留言。请在 百度hi 里边留言。没QQ
还有请给出一个预知结果的窜,我也测试下。
你给出的bsaaaabbbs本程序可以满足。
#include <iostream>
#include <string>
using namespace std;
bool serve = true;
int scorea = 0,scoreb = 0;
int totalscorea = 0 ,totalscoreb = 0;
void showscore();
string change(int iscore);
void judge(int iscorea,int iscoreb);
void totalscroe();
int tosca[30];
int toscb[30];
int aaaaaa = 0;
bool quit = true;
void main(void)
{
char input;
for(int i=0 ;i<30;i++)
{
tosca[i] = 0;
toscb[i] = 0;
}
while(quit)
{
cin >> input;
switch(input)
{
case 'A':
case 'a':
scorea++;
break;
case 'B':
case 'b':
scoreb++;
break;
case 'S':
case 's':
showscore();
break;
default:
break;
}
judge(scorea,scoreb);
}
showscore();
totalscroe();
system(pause);
}
void judge(int iscorea,int iscoreb)
{
if ((iscorea >= 4) &&
((iscorea - iscoreb) >= 2)
)
{
totalscorea ++;
serve = !serve;
tosca[aaaaaa] = scorea;
aaaaaa++;
tosca[aaaaaa] = scoreb;
aaaaaa++;
scorea = 0;
scoreb = 0;
}
if ((iscoreb >= 4) &&
((iscoreb - iscorea) >= 2)
)
{
totalscoreb ++;
serve = !serve;
tosca[aaaaaa] = scorea;
aaaaaa++;
tosca[aaaaaa] = scoreb;
scorea = 0;
scoreb = 0;
}
if (totalscorea >= 3)
{
quit = false;
}
if (totalscoreb >= 3)
{
quit = false;
}
}
void showscore()
{
//显示开球信息
if (serve)
{
cout << Team
A to
serve: <<endl;
cout << totalscorea << - << totalscoreb<<endl;
cout << change(scorea) << - << change(scoreb) <<endl;
//cout << scorea << - << scoreb <<endl;
}
else
{
cout << Team
B to
serve:<<endl;
cout << totalscoreb << - << totalscorea<<endl;
cout << change(scoreb) << - << change(scorea) <<endl;
//cout << scoreb << - << scorea <<endl;
}
}
string change(int iscore)
{
string str = LOVE;
switch(iscore)
{
case 1:
str = 15;
break;
case 2:
str = 30;
break;
case 3:
str = 40;
break;
case 4:
str = A;
break;
default:
break;
}
return str;
}
void totalscroe()
{
//Team
? wins:
?-?
?-?
?-?
?-?
serve = !serve;
if (serve)
{
cout << Team A wins:;
for(int i=0;i<aaaaaa;)
{
cout << tosca[i] << - << tosca[i+1] <<
;
i++;
i++;
}
cout << endl;
}
else
{
cout << Team b wins:;
for(int i=0;i<aaaaaa;)
{
cout << tosca[i] << - << tosca[i+1] <<
;
i++;
i++;
}
cout << endl;
}
}