- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
求解野人与传教士问题1(Solving savage and missionary problems 1)
求解野人与传教士问题1(Solving savage and missionary problems 1)
Title: there are n missionaries and M savages coming to the river. They plan to take a cloud from the right bank to the left bank. The load capacity is two people. At any time, if the number of savages exceeds the number of missionaries, the savages will eat the missionaries. How can they safely ferry all the people across the river?
Topic analysis:
The structure of a node is defined: a sort of back and forth as a search step, so that the node can be described by the following content: on both sides of the number of missionaries and savages, the number of nodes from the starting node distance from the initial node to search after a few steps to the number of nodes. It should be noted that not all nodes are reachable. In the subject, the reachable nodes are restricted, and only two people on the shore must not be negative.
Define connections: the connections between the two nodes can be described from the right to the left bank, the number of missionaries on the ship, the number of savages, the number of ships on board, the number of missionaries, and the number of savages. Since there are only two people on board, there is no winning system.
There are 4 kinds of connections to choose from: two people go to the left bank by boat, one returns; two go to the left bank, two return; one goes to the left bank, two return; a man goes to the left bank and a man returns. Given the fact that this example focuses on the search algorithm, the program takes into account only the first connection, and in the later explanation of the stretch () function, a method for modifying the program that considers the 4 connections is given.
Program source code and explain:
#includestdio.h
#includestdlib.h
#define maxloop / / 100 maximum search distance
#define pristnum 3 / the default initial number
#define slavenum 3 / / Savage default number
Struct SPQ
{
Int Sr, PR; / / number of ship running a back and forth on the right bank of the r
您可能关注的文档
- 惩罚人的小游戏(A game of punishing people).doc
- 想你,在忽 然之间_灌水专区_天涯社区(Miss you, and suddenly _ irrigation area _ Tianya.).doc
- 情商竞争力5情商与企业培训人际关系(EQ 5 EQ and enterprise training interpersonal relationship).doc
- 惩罚函数程序(Penalty function program).doc
- 感人肺腑的爱情短信(Touch one deeply in the heart love messages).doc
- 感冒后的饮食禁忌(Diet taboo after catching cold).doc
- 意象~~(Image ~!).doc
- 感冒误区及攻略(Cold misunderstanding and strategy).doc
- 感动中国2011颁奖词(Touching the 2011 Prize speech of China).doc
- 感动作文(记叙、抒情。。)(Moving composition (narrative, Lyric).. )).doc
- 求职面试礼仪的六个注意(Six tips for job interview etiquette).doc
- 汇编-显示小数(Assembler - display decimal).doc
- 汇编指令 ibm-pc汇编语言指令集(Assembly instruction, IBM-PC assembly language, instruction set).doc
- 汇编技术步步高(BBK).doc
- 水景设计(Waterscape design).doc
- 汇编语言时钟(Assembly language clock).doc
- 汉之云 炼化(Cloud refining of Han Dynasty).doc
- 水果的全面知识(Comprehensive knowledge of fruit).doc
- 汇编知识(compiled knowledge).doc
- 汉子意思不同的日语(Men speak different Japanese).doc
文档评论(0)