English 中文(简体)
伪编码中的 <-和 <- >
原标题:<--- and <-> in pseudocode
  • 时间:2012-05-25 16:36:13
  •  标签:
  • pseudocode

我不是CS背景的人,我试图弄清楚什么是用来做什么的。

for i <---  1 to n-1 do
j <--- find-Min(A,i,n)
A[j] <-> A[i]
end for 

用来指什么?

最佳回答

的意思是“将右手侧指派到左手侧”(在 < code> for 案中使用此词有点奇怪,因为那里很容易省略)。

表示“ swap”。 A[j] 值与 A[i] 互换。

<强度 > EDIT :

我突然想到第一行可能缺失 i ,改为:

for i <---  1 to n-1 do

这成为了上述 的合法使用案例: > 是从 1 的指定值, 依次是 > n-1 ,循环体(下至 end for ,它表示循环的结束)为这些 > 的每一个值执行。

问题回答

关于伪编码中使用的标记,目前还远远没有达成普遍一致。

在此情况下我猜想 意指“ 将右侧指派到左侧”, 而 意指将右侧和左侧互换 。

但是,在第一种情况下,我认为你错过了一个角色。它可能应该是:

for i <--- 1 to n-1 do

所以它是一个普通的 环的 代码, 以下列方式写入 :

for i = 1 to n-1

BASIC中,或:

for (i=1; i<n; i++)

以C类语言写成。

Left arrow for assignment

用于表明变量收到一个新的值,例如:

for i <- 1 to n-1 do 

我从以下几个方面看到这一点:

  • mainly pseudo code;
  • R, S, Scala and OCaml;
  • with an own left arrow symbol in APL.

Left-right-arrow for swapping elements

也用来使行动以象征性的方式显露出来。

我现在除了假代码什么都想不出来





相关问题
Pseudo codestructure to Mysql?

Can somebody help get the following pseudocode in mysql? The resulting selects in the IF statement all return the same columns (4) and multiple rows (unknown) so that s not really the problem i m ...

Assembler Language Programming

I am trying to write a program that inputs a positive number less than 10 and outputs the sum of the first numbers. For example 5 would be 5+4+3+2+1. The commands are Stop, Load, Store, Add, Sum, ...

Job scheduling problem

I m working on an application where I need to automatically schedule jobs for members on a rotating schedule. I m not very good at explaining rules, so here s some data to help out: Positions: A job ...

Explain this DSP notation

I m trying to implement this extenstion of the Karplus-Strong plucked string algorithm, but I don t understand the notation there used. Maybe it will take years of study, but maybe it won t - maybe ...

Pseudocode for getting order based on Dependency

Ok, my situation is this I have a list of items and I need to get the order of these items based on the references they have. For example lets say we have these items: A,B,C,D,E,F C and D have no ...

热门标签