你能帮忙算法吗? [英] could you help about algorithm

查看:88
本文介绍了你能帮忙算法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先

i这个网站是新的

i有一个问题来开发一个关于它的算法

firstly
i am new in this site
i have a problem to develop a algorithm about that

推荐答案


问题是我们应该编写一个可以计算方法1到9的计数的问题,但我们不能用对角线方式例如,我们不能从1开始。我们可以从1
开始2或5
problem is that we should write a problem that can calculate the counts of ways 1 to 9 but we can''t use diagonal way for instance we can''t go 5 from 1. we can go 2 or 5 from 1



你的意思是我们可以去2或4表格1 ?


你还没有说好问题,对于inst你没有说过,一旦你去过它就不能回到广场了。


既然你没有说明那么我去的时候我可以回到广场它可以不止一次访问一个广场,因此有无数的解决方案,例如


1 4 5 2 3 6 9

1 4 5 2 1 4 5 2 3 6 9

1 4 5 2 1 4 5 2 1 4 5 2 3 6 9

1 4 5 2 1 4 5 2 1 4 5 2 1 4 5 2 3 6 9





除非说明所有条件,否则无法创建算法来解决问题。

A ssume you mean "we can go 2 or 4 form 1"?

You have not stated the problem well enough, for instance you have not stated that you can not go back to a square once you have visitied it.

Since you have not stated that then I can go back to a square once I have visited it a can visit a a square more than once and therefore there are an infinite number of solutions e.g.

1 4 5 2 3 6 9
1 4 5 2 1 4 5 2 3 6 9
1 4 5 2 1 4 5 2 1 4 5 2 3 6 9
1 4 5 2 1 4 5 2 1 4 5 2 1 4 5 2 3 6 9

and so on

Until you state all the conditions it would be impossible to create a algorithm to solve the problem.


是的你是真的我写错了我很抱歉

其实我想说我们可以从1开始2或4但是我们不能从1到5,因为它是对角线的方式。问题是有多少种方式可以去9.开始点是1.当然我们不能在某种程度上同一点

例如下面的一个是假的

1236523(因为我们两次访问3点所以这一点是假的)


如果你再帮助我,我会很高兴。

注意:我发布此消息,同时我尝试解决,但我还不能
yeah you are true i wrote wrong i am sorry for that
actually i wanted to say we can go 2 or 4 from 1.But we can''t go to 5 from 1 because it is diagonal way. The problem is that how many ways are there that go to 9.Starting point is 1. Sure we can''t go same point on a way
for instance the following one is false
1236523 ( because we visit the 3 point twice so this one is false)

if you help me again i would be happy.
Note: i post this message and at the same time i try to solve but i can''t yet


我想我会去一个递归函数,传递给函数2数组,1指示我们去过哪个方格,1表示我们去过它们的顺序。


任何给定的方格都知道它的退出选项是什么,所以依次转到任何退出选项尚未访问过的,确保将当前级别标记为已访问并将其添加到被访问的订单数组。


当您点击9时,然后增加解决方案的数量,如果需要的话从订单访问数组中打印路径。
I think I would go with a recursive function, pass to the function 2 arrays, 1 indicating which squares we have already been to and 1 indicating the order we went to them.

Any given square knows what it''s exit options are so go to any exit option in turn that has not already been visited making sure to mark the current level as visited and add it to the visited order array.

When ever you hit 9 then increment the count of solutions and if required print the route from the order visited array.


这篇关于你能帮忙算法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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