【问题标题】:Can anybody help understand what is meant in this pseudocode?任何人都可以帮助理解这个伪代码的含义吗?
【发布时间】:2012-11-13 11:17:09
【问题描述】:

我有一个与 Koch Snowflake 和堆栈/队列有关的任务。问题是我们这里的许多人无法弄清楚作业中给出的伪代码“提示”是什么意思。有人可以帮忙吗?

http://web.cs.mun.ca/~rod/W12/cs2710/assign/a5/assign5.html

Add the initial segments, L.add(seg1) ... L.add(segN)
while not L.isEmpty()
    seg = L.remove()
    if seg is smaller than the minimum segment size then
         draw seg, no new segments are created
    else
        create four new segments according to
        the rules for Koch snowflakes
        add these new segments to L

最令人困惑的部分是“如果 seg 小于最小段大小”......不知道我需要比较什么来写这个。

【问题讨论】:

    标签: java recursion stack queue


    【解决方案1】:

    最小分段大小显然是算法的一个可配置参数,它指定绘制雪花的精细细节级别。

    【讨论】:

      【解决方案2】:

      段是线段:来自您的文档:

      “Segment是一个代表线段的类”

      所以它将是在屏幕上绘制的一条线。
      你应该先看看科赫雪花的样子:http://en.wikipedia.org/wiki/Koch_snowflake

      现在更容易理解了:“

      如果 seg 小于最小段大小,则

      这是一个所谓的“中断条件”,这意味着线条足够小,可以在屏幕上绘制。 (否则会被细分,请参阅上面的 Wiki 链接)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-10-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-06-13
        • 1970-01-01
        相关资源
        最近更新 更多