|
试题描述
|
|
输入
|
|
输出
|
|
输入示例
|
|
WWWWWWWWWWWWWWWWWWWW
WWLWE |
|
输出示例
|
|
11:0
11:0 1:1 21:0 2:1 |
C++程序:
#include<cmath>
#include<iostream>
using namespace std;
main() {
char c;
int a[10000][2],b=0,d=0,i,l=0,p=0,w=0;
while(1) {
cin>>c;
if(c=='E')
break;
if(c=='W') {
w++;
b++;
} else if(c=='L') {
l++;
d++;
}
if((w>=11||l>=11)&&abs(w-l)>=2) {
cout<<w<<':'<<l<<endl;
w=0;
l=0;
}
if((b>=21||d>=21)&&abs(b-d)>=2) {
a[++p][0]=b;
a[p][1]=d;
b=0;
d=0;
}
}
cout<<w<<':'<<l<<"\n\n";
for(i=1; i<=p; i++)
cout<<a[i][0]<<':'<<a[i][1]<<endl;
cout<<b<<':'<<d;
}
使用C++编程实现乒乓球比赛计分系统
本文介绍了一个用C++编写的乒乓球比赛计分系统,详细阐述了程序设计思路,包括如何记录和更新分数,以及实现比赛规则的关键代码片段。
1508

被折叠的 条评论
为什么被折叠?



