Bowling Problem __string

Source: Internet
Author: User
Tags rounds
/*
"Mock Test": Bowling (normal)

Time limit:1000ms Memory limit:65536k
Total submit:58 Accepted:9

Description

Bowling is the use of a ball to hit 10 standing pillars, the column knocked down. A round of 10 rounds, one or more rounds per roll, scoring on the basis of the number of columns to be knocked down. A game has to be divided into 10 rounds of the sum of points, and each round of the score is not only related to this roller, but also may be related to the subsequent one or two rounds of rolling ball situation. That is, the number of columns to be knocked down by a certain round of the ball should not only be counted into this round score, but also may be accounting into the first one or two rounds of scoring. The specific rules and scoring methods of the rolling ball column are as follows:
(1) If the first round of the ball to knock down all 10 columns, then this round will not roll the ball (if the tenth round will also need
Plus two times the ball, you can call it the 11th and 12th rounds, not all the cases need to roll the 11th and 12th round ball. The wheel score is the sum of the number 10 of the knockout columns and the subsequent two times of the ball-knocking.
(2) If the first round of the ball does not knock down 10 columns, you can roll the ball to the remaining columns. If this
Two times the rolling ball to knock down all 10 columns, then this round no longer the ball (if the tenth round will also need to add a ball), the round score
For these two knocks the sum of the number 10 and the number of columns to be knocked down after the second ball.
(3) If a round of two times the ball does not knock down all 10 columns, then this round will not continue to roll the ball, the round score for the two
The sum of the number of columns to be knocked down by the ball.
In short, if-one ball in the wheel or two times the ball to knock down 10 columns, then this round is the first round of the ball rolling started
The sum of the number of columns (one or two of which is not a rolling ball) that has been rolled three times in a row. If you roll the ball two times in a round, knock down the column
If the number is less than 10, the sum of these two knockout columns will be the first round of the score. The following examples illustrate the following (the character "/" means knocking down all columns on the current fairway):
Round 1 2 3 4 5 6 7 8 9 10 11-12
Batting situation///72 9/81 8//9//8/
Each round score 30 27 19 9 18 9 20 20 20 20
Total Total score 30 57 76 85 103 112 132 152 172 192
Now you can write a bowling real time scoring program that calculates and displays the score after the end of a round. If the score for a certain round is not available, the score is not shown.


Input

The input data is bowling.in with a file, the contents of the file are only one row, the case of the previous rounds, each round of the ball with one to two characters, each of the characters represents a hit, the character "/" to knock down the current fairway all the columns, Otherwise, a numeric character indicates the number of columns on the current fairway that the ball is knocked down, separated by a space character between the two rollers.
As the previous example, the corresponding input file content is:///72 9/81 8//9//8/


Output

Output to file Bowling.out, a total of two lines, the first behavior of each round score, the second act to the current round of the total score. Each score is separated by a space.

Sample Input


///72 9/81 8//9//8/

Sample Output


30 27 19 9 18 9 20 20 20 20
30 57 76 85 103 112 132 152 172 192


*/
#include < stdio.h >
#include < string. h >
#define MAX 21


int main (void)
{
Char C,st[max];
int A[max] = {0},b[max] = {0};
int i,j,total = 0, t = 0, now = 0, temp;
while ((c = GetChar ())!= ")
{
if (c!= ')
st[+ + t] = C;
}


for (i = 1, j = 1; I <= 10; i + +)
{
if (st[j] = = '/')
{
now = 10;
if (st[j + 1] = = '/')
{
now = 10;
if (st[j + 2] = = '/')
now = 10;
Else
Now + = St[j + 2]-' 0 ';
}

else/* Consider whether the subsequent sexual condition is continuous.
{
if (st[j + 2] = = '/')
now = 10;
Else
Now + = St[j + 1]-' 0 ' + st[j + 2]-' 0 '; }

j + + 1;
}

Else
{

if (st[j + 1] = = '/')
{
if (st[j + 2] = = '/')
now = 20;
Else
now = ten + St[j + 2]-' 0 ';
}
Else
now = st[j]-' 0 ' + st[j + 1]-' 0 ';

J + + 2;
}

Total = now;
A[i] = now;
B[i] = total;
}


for (i = 1; I <= i + +)
printf ("%d", a[i]);
printf ("");
for (i = 1; I <= i + +)
printf ("%d", b[i]);
printf ("");

return 0;
}


#include < stdio.h >
#include < string. h >
#define MAX 21

int count (char ch)
{
if (ch = = '/')
return 10;
Else
Return (CH-' 0 ');
}

int main (void)
{
Char C,st[max];
int A[max] = {0},b[max] = {0};
int i,j,total = 0, t = 0, now = 0, temp;
while ((c = GetChar ())!= ")
{
if (c!= ')
st[+ + t] = C;
}


for (i = 1, j = 1; I <= 10; i + +)
{
if (st[j] = = '/')
{
now = 10;
if (st[j + 1] = = '/')
Now = + count (st[j + 2]);

else/* Consider whether the subsequent sexual condition is continuous.
{
if (st[j + 2] = = '/')
now = 10;
Else
now = = COUNT (st[j + 1]) + count (St[j + 2]);
}

j + + 1;
}

Else
{

if (st[j + 1] = = '/')
Now = ten + count (St[j + 2]);
Else
Now = count (St[j]) + count (st[j + 1]);

J

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.