登录
首页 » 终端 » 关于猎人过河问题 要解决这个问题就要使过河时载两个过河,返回时尽量只有一个回来。用一个字符串数组来存猎人,狼,羊,白菜;下标依次为0,1,2,3;但他们都有河这...

关于猎人过河问题 要解决这个问题就要使过河时载两个过河,返回时尽量只有一个回来。用一个字符串数组来存猎人,狼,羊,白菜;下标依次为0,1,2,3;但他们都有河这...

于 2022-09-15 发布 文件大小:5.91 kB
0 142
下载积分: 2 下载次数: 1

代码说明:

关于猎人过河问题 要解决这个问题就要使过河时载两个过河,返回时尽量只有一个回来。用一个字符串数组来存猎人,狼,羊,白菜;下标依次为0,1,2,3;但他们都有河这边和那边两种状态;为方便则定义一个结构,只含一个int型变量n;当在河这边时n设为0;在河那边时n设为1。由于每次过河与返回都要考虑狼能否吃羊或羊能否吃白菜;则需要一个函数来判断每次选择是否满足条件。-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 facilitate 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 whether the wolf can eat the sheep吃羊or cabbage you need a function to determine each choose whether or not to meet the conditions.

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 莫尔斯电码
    一个控制台转换器可将转换到字母和同样的圆的莫尔斯电码。欢迎大家下载、试用。谢谢大家的支持!
    2022-01-31 00:42:55下载
    积分:1
  • 反射
    用于获取类型信息在运行时使用反射对象。授予的正在运行元数据的访问权限的类是程序的 System.Reflection 命名空间中。System.Reflection 命名空间包含允许您获取有关应用程序的信息,动态地添加到应用程序的类型、 值和对象的类。ReflectionReflection 的应用程序具有以下应用程序: 它允许查看属性信息在运行时。它允许检查各种类型的程序集,并实例化这些类。它允许后期绑定到方法和 propertiesIt 允许在运行时创建新的类型,然后执行一些任务,使用这些类型。查看 MetadataWe 有提及在前一章使用反射,您可以查看的属性信息。System.Reflection 类的检索对象,需要将其初始化为发现与类关联的属性。若要执行此操作,您定义目标类的 as:System.Reflection.MemberInfo 信息对象 = typeof(MyClass) ;下面的程序演示了这一点: 使用系统 ;[AttributeUsage(AttributeTargets.All)] 公共类 HelpAttribute: 用于 {公共只读字符串 Url ; 公共字符串主题 / 主题是一个命名的参数 {{返回主题 ;} 得到设置 {主题 = 值;}} 公共 HelpAttribute(string url) / / url 是一个定位的参数 {这。Url = url ;} 专用的字符串的主题 ;} {} [HelpAttribute (MyClass 类"信息")] 类 MyClass 命名空间 AttributeAppl {类程序 {静态 void 主要 (字符串 [] args) {System.Reflection.MemberInfo 信息 = typeof(MyClass) ; 对象 [] 属性 = info。GetCustomAttributes(true) ;为 (int 我 = 0 ; 我 < 属性。长度 ;i + +) {System.Console.WriteLine(attributes[i]) ;}Console.ReadKey() ;}}} 编译和运行,它将显示附加到 MyClass:HelpAttribute 示例本示例类的自定义属性的名称时,我们使用前面的章节中使用反射创建的 DeBug
    2022-09-18 10:30:09下载
    积分:1
  • C HANOR prepared by the algorithm source code, since that was the good, huh
    我用C编写的汉诺塔算法的源程序,自认为写的不错,-C HANOR prepared by the algorithm source code, since that was the good, huh
    2022-03-23 22:04:30下载
    积分:1
  • 一个关于分窗口程序,是用Visual C++编写。
    a program about dividing window,which is written with Visual C++.
    2022-02-01 00:51:07下载
    积分:1
  • 先输入图的各顶点名,再输入图的邻接矩阵从而建立图,并用笛施卡尔,普里姆等三种方法求其最小生成树,...
    先输入图的各顶点名,再输入图的邻接矩阵从而建立图,并用笛施卡尔,普里姆等三种方法求其最小生成树,-input vertices of the plan, and plans to import the adjacency matrix thereby establishing map, and use flute Shi Carl prim other three methods for the minimum spanning tree,
    2022-06-16 23:23:37下载
    积分:1
  • 天津航道开发局第一船控制系统
    耙头船舶控制系统 是天津市航道局研制开发-first ship control system in Tianjin Waterway Development Authority
    2022-06-28 14:40:10下载
    积分:1
  • example code of thundering process by vc++6.0,can run
    vc++6.0异常处理演示源代码,运行通过-example code of thundering process by vc++6.0,can run
    2022-01-28 12:33:07下载
    积分:1
  • 在vs.net2002平台实现。模板函数的实现,是学习com+技术的基础。...
    在vs.net2002平台实现。模板函数的实现,是学习com+技术的基础。-in vs.net2002 platform. Template function of the realization of learning com technology is the foundation.
    2022-06-15 21:32:37下载
    积分:1
  • 八皇后问题,用C++编程,在VC++上运行正确,效率还不错...
    八皇后问题,用C++编程,在VC++上运行正确,效率还不错-eight Queen"s problems, and use C++ programming in Visual C++ running on the right, also good efficiency
    2022-03-23 13:51:43下载
    积分:1
  • 不错的代码,很好用 不错的代码,很好用 不错的代码,很好用...
    不错的代码,很好用 不错的代码,很好用 不错的代码,很好用-good,jsgood,jsgood,jsgood,jsgood,jsgood,js
    2022-01-26 02:40:50下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载