The challenge is to find all the pairs of two integers in an unsorted array that sum up to a given S.
For example, if the array is [3, 5, 2, -4, 8, 11] and the sum is 7, your program should return [[11, -4], [2, 5]] because 11 + -4 = 7 and 2 + 5 = 7.
Start
Declare array array
Declare array array2d
Declare variable s
Read array from the keyboard
Read s
for i = 0 to array length do
for j = 1 to array length-1 do
sum=array[i]+array[j]
if sum=s then
Set array2d = [array[i],array[j]]
end if
end for
end for
Display array2d
Stop
Comments
Leave a comment