Enter an ordered array and a number to find two numbers in the array so that they are exactly the number entered. If there are many pairs of numbers and equals the input number, the output can be any pair. For example, input arrays 1, 2, 4, 7, 11, 15, and number 15. Because of the 4+11=15, the outputs are 4 and 11.
1#include <stdio.h>2#include <stdlib.h>3 4 voidFindtwo (int*array,intLenintsum)5 {6 intBeg =0;7 intEnd = len-1;8 intcursum;9 while(Beg <end)Ten { OneCursum = Array[beg] +Array[end]; A if(Cursum = =sum) - { -printf"%d +%d =%d\n", array[beg],array[end],sum); thebeg++; -end--; - } - Else if(Cursum <sum) +beg++; - Else +end--; A } at } - - intMain () - { - intarray[6] = {0,2,4,7, One, the}; -Findtwo (Array,6, -); inSystem"Pause"); - return 0; to}
Enter an ordered array and a number to find two numbers in the array, so that their and exactly the number entered