As for the problem of hunters crossing the river, to solve this problem, it is necessary to carry tw
2016-08-22
0 0 0
no vote
Other
Earn points
As for the problem of hunters crossing the river, to solve this problem, it is necessary to carry two hunters crossing the river and only one comes back as far as possible. Use a string array to store hunter, wolf, sheep and cabbage; the subscripts are 0, 1, 2 and 3 in turn; but they all have two states on the side of the river and on the other side; for convenience, define a structure with only one int variable n; when n is set to 0 on the side of the river; when n is set to 1 on the other side of the river. Because whether the wolf can eat the sheep or whether the sheep can eat the cabbage should be considered in every crossing and return, a function is needed to judge whether each selection meets the condition. -Hunters across the river on the issues to resolve this issue so we should cross the river when the two set out across the river to return to when there is only one back as far as possible. Using a string array to keep hunters, the wolf, sheep, and cabbage subscript followed by 0,1,2, 3 but they have a river here and there two states to facility the definition of a structure containing only an int variable n when in the river here when n is set to 0 in the river when n is set to one side. Due to cross the river and return each time to consider when the wolf can eat the sheep or litter you need a function to determine each choose whether or not to meet the conditions.
关于
猎人
过河
问题
这个
返回
一个
字符串
数组
Related Source Codes
获取窗口及子控件句柄
0
0
no vote
MVC Warehouse Management WMS System Source Code
0
0
no vote
VC port operation module
0
0
no vote
SNMP C++library
0
0
no vote
VC pure code realizes LED digital clock
0
0
no vote
No comment