2014-10-17 98 views
0

我需要在数组中显示偶数(在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 
+2

您应该在循环内写入的伪代码是'if is_even(count)then print(count)'。 – 2014-10-17 16:34:35

回答

2

使用模测试,如果数字是偶数。所以像这样:print < - 如果MOD(数字[count])== 0

0

这里是一些应该根据需要做的伪代码。让我知道你是否需要任何澄清。

function write_evens(A array of integers) 
    int i = 0; 
    while i < A.length 
     if (i%2 == 0) 
      print A[i] + " " 
     i++ 
+0

我更新了我原来的问题到我到目前为止。 – Ajzimmerman 2014-10-17 17:26:07