Monday, February 20, 2012

Pairs of integers that sum to a given value.


Given an array with integers and a number n, design an algorithm and write code to print all pairs of integers that sum up to this number.


Code input/output:
int [] A = {5, 9, 2, 11, 3, 8, 15, 7, 4, 12, 1};


Pairs that sum up to 12
5:7
9:3
11:1
8:4


No comments:

Post a Comment