算法学习,请问这道算法题怎么做思路是什么?
Createaprogram,which,givenavalidsequenceofrollsforonelineofAmericanTen-PinBowling,pro...
Create a program, which, given a valid sequence of rolls for
one line of American Ten-Pin Bowling, produces the total
score for the game. This is a summary of the rules of the game:
Each game, or "line" of bowling, includes ten turns, or "frames"for the bowler.
In each frame, the bowler gets up to two tries to knock down all the pins.
If in two tries, he fails to knock them all down, his score for that frame is the total number of pins Knocked down in his two tries.
If in two tries he knocks them all down, this is called a "spare" and his score for the frame is ten plus the number of pins knocked down on his next throw (in his next turn).
If on his first try in the frame he knocks down all the pins, this is called a "strike" His turn is over, and his score for the frame is ten plus the simple total of the pins knocked down in his next two rolls.
If he gets a spare or strike in the last (tenth) frame, the bowler gets to throw one or two more bonus balls, respectively. - These bonus throws are taken as part of the same turn. If the bonus throws knock down all the pins, the process does not repeat: the bonus throws are only used to calculate the score of the final frame.
Kata: Bowling Game
The game score is the total of all frame scores.
Here are some things that the program will not do:
We will not check for valid rolls.
We will not check for correct number of rolls and frames.
We will not provide scores for intermediate frames.
The input is a scorecard from a finished bowling game, where "X" stands for a strike, "-" for no pins bowled, and "/" means a spare. Otherwise figures 1-9 indicate how many pins were knocked down in that throw.
Sample games:
12345123451234512345
always hitting pins without getting spares or strikes, a total score of 60
XXXXXXXXXXXX
a perfect game, 12 strikes, giving a score of 300
9-9-9-9-9-9-9-9-9-9-
heartbreak - 9 pins down each round, giving a score of 90
5/5/5/5/5/5/5/5/5/5/5
a spare every round, giving a score of 150 展开
one line of American Ten-Pin Bowling, produces the total
score for the game. This is a summary of the rules of the game:
Each game, or "line" of bowling, includes ten turns, or "frames"for the bowler.
In each frame, the bowler gets up to two tries to knock down all the pins.
If in two tries, he fails to knock them all down, his score for that frame is the total number of pins Knocked down in his two tries.
If in two tries he knocks them all down, this is called a "spare" and his score for the frame is ten plus the number of pins knocked down on his next throw (in his next turn).
If on his first try in the frame he knocks down all the pins, this is called a "strike" His turn is over, and his score for the frame is ten plus the simple total of the pins knocked down in his next two rolls.
If he gets a spare or strike in the last (tenth) frame, the bowler gets to throw one or two more bonus balls, respectively. - These bonus throws are taken as part of the same turn. If the bonus throws knock down all the pins, the process does not repeat: the bonus throws are only used to calculate the score of the final frame.
Kata: Bowling Game
The game score is the total of all frame scores.
Here are some things that the program will not do:
We will not check for valid rolls.
We will not check for correct number of rolls and frames.
We will not provide scores for intermediate frames.
The input is a scorecard from a finished bowling game, where "X" stands for a strike, "-" for no pins bowled, and "/" means a spare. Otherwise figures 1-9 indicate how many pins were knocked down in that throw.
Sample games:
12345123451234512345
always hitting pins without getting spares or strikes, a total score of 60
XXXXXXXXXXXX
a perfect game, 12 strikes, giving a score of 300
9-9-9-9-9-9-9-9-9-9-
heartbreak - 9 pins down each round, giving a score of 90
5/5/5/5/5/5/5/5/5/5/5
a spare every round, giving a score of 150 展开
展开全部
求答案 ?
一筐鸡蛋:
1个1个拿,正好拿完。
2个2个拿,还剩1个。
3个3个拿,正好拿完。
4个4个拿,还剩1个。
5个5个拿,还剩1个
6个6个拿,还剩3个。
7个7个拿,正好拿完。
8个8个拿,还剩1个。
9个9个拿,正好拿完。
问筐里有多少鸡蛋?
1个1个拿正好拿完,3个3个拿正好拿完,7个7个拿正好拿完,9个9个拿正好拿完,框子里鸡蛋的个数是4*9=63的倍数。
2个2个拿剩1个,5个5个拿剩余1个,个位数是1。
所以从以下数中找: 63×7、 63×17 、63×27 、63×37……
所以最小数是441个
一筐鸡蛋:
1个1个拿,正好拿完。
2个2个拿,还剩1个。
3个3个拿,正好拿完。
4个4个拿,还剩1个。
5个5个拿,还剩1个
6个6个拿,还剩3个。
7个7个拿,正好拿完。
8个8个拿,还剩1个。
9个9个拿,正好拿完。
问筐里有多少鸡蛋?
1个1个拿正好拿完,3个3个拿正好拿完,7个7个拿正好拿完,9个9个拿正好拿完,框子里鸡蛋的个数是4*9=63的倍数。
2个2个拿剩1个,5个5个拿剩余1个,个位数是1。
所以从以下数中找: 63×7、 63×17 、63×27 、63×37……
所以最小数是441个
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |