55 lines
1.7 KiB
Plaintext
55 lines
1.7 KiB
Plaintext
'Task
|
|
'Simulate/translate the above PL/I program snippet as best as possible
|
|
' in your language, with particular emphasis on the do loop
|
|
' construct.
|
|
'The do index must be incremented/decremented in the same order shown.
|
|
'If feasible, add commas to the two output numbers (being displayed).
|
|
'Show all output here.
|
|
|
|
'Unknown DO multiple conditions behaviour:
|
|
' this code implements a sequential/serial set of ranges mode for DO condition
|
|
|
|
Dim As Integer prod, sum, x, y, z, one, three, seven
|
|
Dim As _Integer64 Count(1 To 7)
|
|
Dim As Integer Index, IndexCondition
|
|
|
|
prod = 1
|
|
sum = 0
|
|
x = 5
|
|
y = -5
|
|
z = -2
|
|
one = 1
|
|
three = 3
|
|
seven = 7
|
|
Count(1) = -three
|
|
Count(2) = -seven
|
|
Count(3) = 555
|
|
Count(4) = 22
|
|
Count(5) = 1927
|
|
Count(6) = x
|
|
Count(7) = 11 ^ x
|
|
IndexCondition = 1
|
|
Do
|
|
If IndexCondition = 1 Then
|
|
If Count(1) + three < 3 ^ 3 Then Count(1) = Count(1) + three Else IndexCondition = 2
|
|
ElseIf IndexCondition = 2 Then
|
|
If Count(2) + x < seven Then Count(2) = Count(2) + x Else IndexCondition = 3
|
|
ElseIf IndexCondition = 3 Then
|
|
If Count(3) - 1 > 550 - y Then Count(3) = Count(3) - 1 Else IndexCondition = 4
|
|
ElseIf IndexCondition = 4 Then
|
|
If Count(4) - three > -28 Then Count(4) = Count(4) - three Else IndexCondition = 5
|
|
ElseIf IndexCondition = 5 Then
|
|
If Count(5) + 1 < 1939 Then Count(5) = Count(5) + 1 Else IndexCondition = 6
|
|
ElseIf IndexCondition = 6 Then
|
|
If Count(6) + z < y Then Count(6) = Count(6) + z Else IndexCondition = 7
|
|
ElseIf IndexCondition = 7 Then
|
|
If Count(7) + 1 < 11 ^ (x + one) Then Count(7) = Count(7) + 1 Else Exit Do
|
|
End If
|
|
|
|
sum = sum + Abs(Count(IndexCondition))
|
|
If Abs(prod) < 2 ^ 27 And (j <> 0) Then prod = prod * Count(IndexCondition)
|
|
Print sum
|
|
Print prod
|
|
|
|
Loop
|