Result: Program displays all pairs A.I,A.J with A.I+A.J=X

...
call QUICKSORT N
S = ""; do I = 1 to N; S = S A.I; end; say S "|" X
I = 1; J = N
do until J <= I
select
when A.I + A.J < X then I = I + 1
when A.I + A.J > X then J = J - 1
otherwise
say "("A.I"," A.J") and ("A.J"," A.I")"
I = I + 1; J = J - 1
end
end
if J = I & 2 * A.I = X then say "("A.I"," A.I")"
exit
...

Literature

Knuth D. E. Sorting and Searching, vol. 3 of The Art of Computer Programming