ACM一道题程序改错

来源:百度知道 编辑:UC知道 时间:2024/07/07 18:42:57
Since taking office, ITTF President Adham Sharara has maken some decisions to implement a series of reforms, in order to promote the sport in the global popularity. 11-points system reform has aroused much controversy. Because of the inability to adapt to the new rules, some of the players have to choose to retire. Tom is one of them. After retire, he embarked on the study of table tennis in order to investigate the impact of the different of 11-points and 21-points. In carrying out his research, he need to analyze some statistical data, so he need your help.

First list the outcome of each ball, then calculated the results in the 11-points and 21-points system. For example, there are a copy of the record. 'W' denotes Tom win, 'L' denotes he loss.

WWWWWWWWWWWWWWWWWWWWWWLW

In 11-points system, the result of the game is 11-0 in first and 11-0 in second. Now the third has not end, the current is 1-1. In 21-points system, then the result o

#include <iostream>
using namespace std;
int n=0, m=0, k=0, l=0, M=0, N=0;
int main ()
{

int i[100]={0} , j[100]={0} , g[100]={0} , h[100]={0};
char ch;
do
{
cin>>ch;
if (ch=='E') break;
if (ch=='W')
{
n++;
N++;
}
if (ch=='L')
{
m++;
M++;
}

if ( n==11 || m==11 ) //错误之处
{
i[k]=n;
j[k]=m;
n=0;
m=0;
k++;
}

if ( N==21 || M==21 ) //错误之处
{
g[l]=N;
h[l]=M;
N=0;
M=0;
l++;
}
}while (1);
i[k]=n;
j[k++]=m;
g[l]=N;
h[l++]=M;
cout <<i[0]<<":"<<j[0]<<endl;
for (int a=1;a<k;a++)
{
if(i[a] || j[a]) //错误之处
cout <<i[a]<<":"<<j[a]<<endl;
}
cout <<endl;
cout <<g[0]<<":