阻碍蛇形阵列 [英] Obraining Snakelike array

查看:68
本文介绍了阻碍蛇形阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友.如何获得循环内类似蛇形数组的跟踪,如下图所示?

[IMG] http://i49.tinypic.com/2ev3o94.png [/IMG]

Hello Friends. How can I obtain the tracking of snakelike array within loops as shown in figure below?

[IMG]http://i49.tinypic.com/2ev3o94.png[/IMG]

推荐答案

请参阅我对该问题的评论.

这里的想法是:显示图片并不意味着问题的定义.而且,示出一个特定示例也不是问题的定义.举个例子,通常情况下可能会发现一些做不同事情的不同算法,这是一个没有正式描述的一般情况.

该代码几乎就像是一个数学语句:它不仅仅表达某种想法,或多或少地含糊其词.即使某些实际目的并不需要这种绝对的确定性级别,也总是以绝对确定的方式定义某些东西.每个这样的定义或算法在其深度上都具有无穷大的概念:它定义了一些不变的行为,这与代码的编译方式和时间,执行的次数(当然它是无状态的),执行什么操作无关. CPU,什么时间等.它总是定义一些不变的行为,没有任何歧义.因此,对算法的要求应满足此级别或确定性.

也就是说,这是问题的解决方案几乎等同于其严格提法的典型情况之一.这是您要做的:以完全明确的方式,使所有合格的读者都可以完全理解的文本形式表达问题.您将看到它需要严格的数学语言.完成后,您将看到该算法已经存在-您只需将其从您的声明性语言转换为某些命令性语言.如Java.

在很多情况下,这种翻译本身非常困难;并且存在许多尚未解决的问题,这些问题在世界范围内都是众所周知的.但您的情况并非如此.我敢肯定,在您的简单案例中,这就是所有涉及的内容,没有别的了.

考虑一下,我给了你一个通用算法 :-)来解决无限数量的类似问题:严格地制定它,然后立即看到解决方案.

—SA
Please see my comment to the question.

Here is the idea: showing the picture does not mean definition of the problem. Moreover, showing one particular example is also not a definition of the problem. By an example, it''s usually possible to find some different algorithms doing different things is some general case which is not formally described.

The code is pretty much like a statement in mathematics: it does not just express some idea, more or less vague. It always defines something in an absolutely certain way, even when this absolute level of certainty is not required by some practical purpose. Every such definition or algorithm hold the notion of infinity in its depth: it defines some invariant behavior, which does not depend on how and when the code was compiled, how many times executed (it it is stateless, of course), on what what CPU, at what time, etc. It always define some invariant behavior, without any ambiguity. So, the requirements to the algorithm should meet this level or certainty.

That said, this is one of the typical cases, when the solution of the problem is nearly equivalent to its strict formulation. Here is what you have to do: formulate the problem in the form of text fully understandable to all qualified readers, in a fully unambiguous way. You will see that it would require strict mathematical language. As soon as you do it, you will see that the algorithm is already there — you only need to translate it from you declarative language to some imperative language. Such as Java.

There are very many cases, when such translation itself is extremely difficult; and there is a good number of unsolved problems, well known in the world. But not in your case. I''m pretty sure in your simple case this is all what involved, there is nothing else.

Consider I gave you a universal algorithm :-) for solving of unlimited number of similar problems: formulate it strictly, and immediately see the solution.

—SA


这篇关于阻碍蛇形阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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