#K93617. Find Pairs With Target Sum
Find Pairs With Target Sum
Find Pairs With Target Sum
You are given a list of integers and a target integer. Your task is to find all unique pairs \( (a, b) \) from the list such that
[ a + b = target ]
Each pair must be printed with the smaller number first (i.e. \( a \leq b \)). The resulting pairs should be sorted in ascending order based on the first element of each pair. If no valid pair exists, output nothing.
Note: Each pair should be output on a separate line with the two numbers separated by a space.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a single integer \( n \) denoting the number of integers in the list.
- The second line contains \( n \) space-separated integers representing the list.
- The third line contains an integer representing the target sum.
outputFormat
For each valid pair, print a line containing two space-separated integers, where the first integer is less than or equal to the second. The pairs must appear in ascending order of their first element. If there is no pair whose sum equals the target, output nothing.
## sample6
1 2 3 -1 4 6
3
-1 4
1 2
</p>