The following code snippet is hosted on Github Gist.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Read and Write Binary & Text Hybrid Content Stream using C++
The following code snippet is hosted on Github Gist.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A patriarch of Nankai University ACM Association operates a bowling alley after graduation. Now, he needs a program to keep the score for the bowling.
There are ten frames in one game. You have two chances to knock down the ten pins in each frame. There are three possible cases for each frame.
1.MISS
If you fail to knock down all of the ten pins during two delivers in a frame, the score you get from this frame will be the number of the pins that you have knocked down. If your deliver knocks down zero pin, your score board will be marked a "-".
2.SPARE
Getting all ten pins down with a single ball is not as easy as it seems! So, if you leave one or more pins standing after your first delivery, you get a second chance to knock all the pins down. This is your "spare" shot. If you knock all remaining pins down on the second shot you have made your spare. A spare is marked on the scoresheet with a "/".And the score you get will be 10 plus the number of pins you knock down during the next delivery.
3. STRIKE
When the bowler knocks down all ten pins during the first delivery in a frame, it is called a strike. Clearly your score goes up by ten, but like a spare, you get a bonus – the number of pins you knock down during your next two deliveries, which will be added to the score. A strike is on the scoresheet with an "X".
Note that the tenth frame is a little different with others.
(1) If you don't knock down the ten pins, the score will be added by the numbers of pins you knock down.
(2) The tenth frame rewards you with a final bonus ball if you convert your spare. And your score will be added by 10 and the number of pins you knock down during your final bonus delivery.
(3) If you make a strike, you will get two bonus balls. The score will be added by 10 and the number of pins you knock down during your final two bonus deliveries.You can thus throw nine strikes in the first nine frames and, if you get another two in the tenth, the bonus ball means the most strikes you can have in one game is twelve. And the full mark is 300.
Input
Input contains several cases. The input is ended up with the end of file (EOF). Each case includes one line which contains several numbers and signs to record a bowling game. The signs are '-', '/' or 'X'. And the numbers range from 1 to 9. The adjacent signs and numbers are separated by one blank.
Output
For each case, please output two lines. The first line for the i-th input case should be "Case i:". The second line should be 10 integers, standing for the 10 accumulative scores of the frames in a bowling game. And each two adjacent integers should be separated by one blank.
Sample Input
X X X X X 5 / 7 1 - - X X X X
4 4 3 3 2 2 1 7 7 1 2 - 9 / 2 2 6 3 2 / 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters