Description
Flowers is analyzed in the following ways, first of all, the outcome of each ball is listed in a table, and then calculated in the 11-point and 21-point system, the results of the two sides (as at the end of the record).
The rules of the game are the same as the actual game rules, the score is 10:11 in the 11-point system to continue the game until the points gap of 2 points, the same 21 points of the score of 20:21 will continue to play.
For example, there is now a record, (where w means flowers get a point, l means Flowers opponent gets a point):
Wwwwwwwwwwwwwwwwwwwwwwlw
In the 11-point system, the result of the match is flowers the first inning 11:0 wins, the second inning 11:0 wins, is in the third inning, the current score of 1:1. And in the 21-point system, at this time the result of the match is flowers the first inning 21:0 wins, is in the second inning, the score 2:1. If a game starts at the beginning, the score is 0:0.
Your program is for the input of a series of game information (WL form), output the correct results. Input Format
Each input file contains several lines of string (up to 20 letters per line), a string with uppercase W, l, and E, and perhaps a few spaces in between. where e indicates the end of the game information, the program should ignore all the content after E, E may have interference text. output Format
The output consists of two parts, each with several lines, each corresponding to the score of a game (in order of entry). The first part is the result of a 11-point system, and the second part is the result of a 21-point system, separated by a blank line between the two parts. Sample Input 1
Wwwwwwwwwwwwwwwwwwww
Wwlwe Sample Output 1
11:0
11:0
1:1
21:0
2:1 limit
Each test point 1s
Tips
Very simple, careful input output format. ^_^
A simple simulation for the first time WA did not directly find the error, or rewrite it again before the
#include <cstdio>//first 50 points #include <iostream> #include <algorithm> using namespace std;
char s;
int vct,sum;
int a1[10000],a2[10000];
int b1[10000],b2[10000];
int abs (int a) {if (a<0) a=-a;
return A;
} int main () {freopen ("13.in", "R", stdin);
while (Cin>>s) {if (s== ' E ') is break;
if (s== ' W ') {a1[vct]++;
b1[sum]++;
if (A1[vct]>=11&&abs (a1[vct]-a2[vct]>=2)) vct++;
if (B1[sum]>=21&&abs (b1[sum]-b2[sum]>=2)) sum++;
} if (s== ' L ') {a2[vct]++;
b2[sum]++;
if (A2[vct]>=11&&abs (a1[vct]-a2[vct]>=2)) vct++;
if (B2[sum]>=21&&abs (b1[sum]-b2[sum]>=2)) sum++;
}} for (int i=0;i<=vct;i++) printf ("%d:%d\n", A1[i],a2[i]); if (a1[vct+1]| |
A2[VCT+1]) printf ("%d:%d\n", a1[vct+1],a2[vct+1]);
printf ("\ n");
for (int i=0;i<=sum;i++) printf ("%d:%d\n", B1[i],b2[i]); if (B1[sum+1]| |
B2[SUM+1]) printf ("%d:%d\n", b1[sum+1],b2[sum+1]);
return 0; }
#include <iostream>//ac code #include <cmath> #include <string> using
namespace Std;
int main () {string s1,s2;
while (Getline (CIN,S2)) s1+=s2;
int i=0;
int a=0,b=0;
while (s1[i]!= ' E ') {switch (S1[i]) {case ' W ': a++;break;
Case ' L ': b++;break; } if (a>=11| |
b>=11) &&abs (A-B) >=2) {cout<<a<< ': ' <<b<<endl;
a=b=0;
} i++;
} cout<<a<< ': ' <<b<<endl;
cout<<endl;
i=0,a=0,b=0;
while (s1[i]!= ' E ') {switch (S1[i]) {case ' W ': a++;break;
Case ' L ': b++;break; } if (a>=21| |
B>=21) &&abs (A-B) >=2) {cout<<a<< ': ' <<b<<endl;
a=b=0;
} i++;
} cout<<a<< ': ' <<b<<endl;
return 0; }