十三块石头 [英] Thirteen Stones

查看:82
本文介绍了十三块石头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在十三石中比赛中,两名球员交替从一堆13块石头中取出1枚,2枚或3枚
石头,直到没有留下任何石块。最后一位获得一块石头的
玩家是赢家。


我需要制作一个模拟十三块石头的程序。游戏。

我的程序应该交替要求玩家选择他们希望从堆中移除多少石头

。如果选择有效(1,2或

3个宝石),则应从

堆中移除所选数量的宝石。如果玩家输入无效数量的宝石,程序

应显示错误消息并要求玩家再次选择。

继续玩,直到没有留下任何宝石,并且显示消息

表示获胜者。


输入:每回合选择的宝石数量(1,2或3)

输出:宣告获胜者的消息。


有任何提示吗?

解决方案

coinjo写道:

在十三石头中比赛中,两名球员交替从一堆13块石头中取出1枚,2枚或3枚石头,直到没有留下任何石块。拿起石头的最后一名球员是赢家。

我需要制作一个模拟十三块石头的程序。游戏。
我的程序应该交替要求玩家选择他们希望从堆中移除多少石头。如果选择有效(1,2或
3个宝石),则应从
堆中移除所选数量的宝石。如果玩家输入无效数量的宝石,程序将显示错误消息并要求玩家再次选择。
继续游戏直到没有剩余宝石,并显示消息
指示获胜者。

输入:每回合选择的宝石数量(1,2或3)
输出:宣告获胜者的消息。

任何提示请?




接受输入。

流程输入。

生成输出。

换句话说,我们不会为你做功课。尽你所能
努力,向我们展示你的想法,然后我们会帮助你。


见常见问题5.2: http://www.parashift。 com / c ++ - faq-lit ... t.html#faq-5.2




" coinjo" <共**** @ gmail.com>在消息中写道

news:11 ********************* @ g49g2000cwa.googlegro ups.com ...

在十三块石头中比赛中,两名球员交替从一堆13块石头中取出1枚,2枚或3枚石头,直到没有留下任何石块。拿起石头的最后一名球员是赢家。

我需要制作一个模拟十三块石头的程序。游戏。
我的程序应该交替要求玩家选择他们希望从堆中移除多少石头。如果选择有效(1,2或
3个宝石),则应从
堆中移除所选数量的宝石。如果玩家输入无效数量的宝石,程序将显示错误消息并要求玩家再次选择。
继续游戏直到没有剩余宝石,并显示消息
指示获胜者。

输入:每回合选择的宝石数量(1,2或3)
输出:宣告获胜者的消息。

任何提示拜托?




是的。显示一些努力。如果你实际上尝试了,并且当你遇到问题时会花点b $ b,用特定的

问题发布你的代码,那么我们会帮助你。没有人会为你做这件事。


-Mike


coinjo写道:< blockquote class =post_quotes>在十三石头中比赛中,两名球员交替从一堆13块石头中取出1枚,2枚或3枚石头,直到没有留下任何石块。拿起石头的最后一名球员是赢家。

我需要制作一个模拟十三块石头的程序。游戏。
我的程序应该交替要求玩家选择他们希望从堆中移除多少石头。如果选择有效(1,2或
3个宝石),则应从
堆中移除所选数量的宝石。如果玩家输入无效数量的宝石,程序将显示错误消息并要求玩家再次选择。
继续游戏直到没有剩余宝石,并显示消息
指示获胜者。

输入:每回合选择的宝石数量(1,2或3)
输出:宣告获胜者的消息。

任何提示拜托?




如果你真的无法在这个问题上取得一些进展那么

也许你应该考虑另一个方向。编程任务

不容易,它只是一个简单的循环。


现在当然试图解决这个问题你可能会卡住, 's
预计,但你应该能够至少自己尝试解决方案。


john


In "Thirteen Stones" game, two players alternately take 1, 2, or 3
stones from a pile of 13 stones until no stones are left. The last
player to pick up a stone is the winner.

I need to make a program that simulates the "Thirteen stones" game.
My program should alternately ask the players to select how many stones
they wish to remove from the pile. If the selection is valid (1, 2, or
3 stones), the selected number of stones should be removed from the
pile. If a player enters an invalid number of stones, the program
should display an error message and ask the player to select again.
Continue play until no stones are left, and display a message
indicating the winner.

Input: Number of stones (1, 2, or 3) chosen on each turn
Output: A message declaring the winner.

Any hints please?

解决方案

coinjo wrote:

In "Thirteen Stones" game, two players alternately take 1, 2, or 3
stones from a pile of 13 stones until no stones are left. The last
player to pick up a stone is the winner.

I need to make a program that simulates the "Thirteen stones" game.
My program should alternately ask the players to select how many stones
they wish to remove from the pile. If the selection is valid (1, 2, or
3 stones), the selected number of stones should be removed from the
pile. If a player enters an invalid number of stones, the program
should display an error message and ask the player to select again.
Continue play until no stones are left, and display a message
indicating the winner.

Input: Number of stones (1, 2, or 3) chosen on each turn
Output: A message declaring the winner.

Any hints please?



Accept input.
Process input.
Generate output.

In other words, we won''t do your homework for you. Make your best
effort, show us what you''ve come up with, and then we''ll help.

See FAQ 5.2: http://www.parashift.com/c++-faq-lit...t.html#faq-5.2



"coinjo" <co****@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...

In "Thirteen Stones" game, two players alternately take 1, 2, or 3
stones from a pile of 13 stones until no stones are left. The last
player to pick up a stone is the winner.

I need to make a program that simulates the "Thirteen stones" game.
My program should alternately ask the players to select how many stones
they wish to remove from the pile. If the selection is valid (1, 2, or
3 stones), the selected number of stones should be removed from the
pile. If a player enters an invalid number of stones, the program
should display an error message and ask the player to select again.
Continue play until no stones are left, and display a message
indicating the winner.

Input: Number of stones (1, 2, or 3) chosen on each turn
Output: A message declaring the winner.

Any hints please?



Yes. Show some effort. If you actually try, and
when you get stuck, post your code with specific
questions, then we''ll help. Nobody is going to
do it for you.

-Mike


coinjo wrote:

In "Thirteen Stones" game, two players alternately take 1, 2, or 3
stones from a pile of 13 stones until no stones are left. The last
player to pick up a stone is the winner.

I need to make a program that simulates the "Thirteen stones" game.
My program should alternately ask the players to select how many stones
they wish to remove from the pile. If the selection is valid (1, 2, or
3 stones), the selected number of stones should be removed from the
pile. If a player enters an invalid number of stones, the program
should display an error message and ask the player to select again.
Continue play until no stones are left, and display a message
indicating the winner.

Input: Number of stones (1, 2, or 3) chosen on each turn
Output: A message declaring the winner.

Any hints please?



If you really can''t make some progress on that question by yourself then
maybe you should consider another direction. Programming assignments
don''t get much easier, its a single simple loop.

Now of course in attempting to solve this you might get stuck, that''s
expected, but you should be able to at least attempt a solution by yourself.

john


这篇关于十三块石头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆