Problem Description
In football, there are many competitions, such as the World Cup knockout and UEFA Champions League knockout, when the two sides are still dead heat after the regular and overtime games, the penalty shootout is needed to decide who can win the final victory. The rules of penalty shootout are very simple, and the two parties take turns sending players penalty kicks, each with a penalty of 5. If the 5-round penalty is still dead heat after the end, then it will enter a decisive stage. Each party sends a penalty kick to a player until one of them is punished and the other party does not enter.
There are also penalty shootout in the North American professional Hockey League. Unlike the rules of football, it only punishes 3 rounds of penalties and then goes to the stage of winning and losing, while the other rules are exactly the same.
In this case, the input will give you a penalty for each penalty, and your task is to output a "score board".
Input
The input contains multiple sets of data. The first row of each set of data contains an integer N (1<=n<=18), which indicates how many penalty penalties have been fined by both parties, and n=0 indicates the end of the input. Then there are n rows, each of which is a string of the following form:
XXXX good: This penalty is scored
or XXXX No good: Indicates that the penalty is not in the penalty
where xxxx denotes the player's name (all consists of letters and spaces, ensuring that no ambiguity occurs)
Each line is guaranteed to be no more than 100 characters.
XXXX and good as well as XXXX and no, no and good are guaranteed to have only 1 spaces.
Good, no good are lowercase. The subject is case-sensitive.
The data does not guarantee the end of the penalty shootout, nor does it guarantee the end of the set of data immediately after the end of the game (i.e., without judging whether the penalty is over, just add the penalty to the score).
Output
For each set of data, output a score board. A penalty if a penalty is entered, the corresponding place is marked ' O ', if there is no enter the label ' X '. The first free throw of the team information on the top, after the penalty below. On the far right, mark the scores of the two teams. The specific format references the sample output. Note that if a penalty is only one penalty, the place where the penalty is in the back is written '-'.
Sample Input
6
Riise Good
Ballack Good
Gerrard no good
Lampard no good
Fernando Torres Good
Malouda Good
9
Christiano Ronaldo No Good
Messi No Good
Giggs good
Abidal No Good
Carrick Good
Ronaldinho good
Rooney Good
Henry No Good
Tevez Good
0
Sample Output
1 2 3 Score
o X o 2
o X o 2
1 2 3 4 5 Score
X o o o 4
x x O X-1
Tips:
The number of spaces is the same as the sample output, which is likely to be sentenced to "malformed" (Presentation error).
Note: There may be a no in the name as well.
So when judging, you need to judge the end of "No good"! There is a space in front of no!
Java is very powerful ~ directly with EndsWith ("no Good");
ImportJava.util.Scanner;/** * @author Chen Haoxiang * * @version 1.0 2016-5-11 * * Public class Main { Public Static void Main(string[] args) {Scanner SC =NewScanner (system.in); while(Sc.hasnext ()) {intn =sc.nextint (); Sc.nextline ();if(n==0){return; } String str=NULL;CharA[] =New Char[(n+1)/2];CharB[] =New Char[(n+1)/2];intap=0;intbp=0;intanum=0;intbnum=0; for(intI=0; i<n;i++) {str = Sc.nextline ();BooleanIsNo =false;if(Str.endswith ("No Good")) {isno=true; }if(IsNo) {if(i%2==0) {a[ap++]=' X '; }Else{b[bp++]=' X '; } }Else{if(i%2==0) {a[ap++]=' O '; anum++; }Else{b[bp++]=' O '; bnum++; } } } for(intI=1; I<= (n+1)/2; i++) {System.out.print (i+" "); } System.out.println ("Score");if(n%2!=0) {b[(n+1)/2-1]='-'; } for(intI=0;i< (n+1)/2; i++) {System.out.print (a[i]+" "); } System.out.println (Anum); for(intI=0;i< (n+1)/2; i++) {System.out.print (b[i]+" "); } System.out.println (Bnum); } }}
Hdoj/hdu 2,539-point ball Battle (an application of the String.endswith () method ~)