我需要在数组中显示偶数(在Psuedocode中),我完全不知道如何做到这一点。
据我所知:
Begin write_evens(in numbers As Array of Integers, in array_size As Integer)
Declare count As Integer
Set count ← 0
While count < size
*******I'm stuck on what to do in the loop*****
Set count ← count + 1
{编辑}
我在这里:
Begin write_evens(in numbers As Array of Integers, in array_size As Integer)
Declare count As Integer
Set count ← 0
While count < size
If array_size % 2 == 0
Write array_Size
End if
Set count ← count + 1
End
答案 0 :(得分:2)
使用modulo来测试数字是否均匀。所以类似于:print&lt; - 如果MOD(numbers [count])== 0
答案 1 :(得分:0)
这是一些应该按要求做的伪代码。如果您需要任何澄清,请与我们联系。
function write_evens(A array of integers)
int i = 0;
while i < A.length
if (i%2 == 0)
print A[i] + " "
i++