#include
<iostream>
using
namespace
std;
void
Func(int
array[],
int
length,int
thenumber,
int
&num1,
int
&num2)
{
int
head = 0;
int
tail =
length
- 1;
while
(head != tail)
{
int
temp =
array[head] +
array[tail];
if
(temp ==
thenumber)
{
num1
=
array[head];
num2
=
array[tail];
cout
<<
num1
<<'\t'<<
num2<<endl;
head++;
tail--;
continue;
}
if
(temp >
thenumber)
tail--;
else
head++;
}
}
int
main()
{
int
abc[] = { 0,1,3,5,6,8,9,11,12,13,14,15,16 };
int
length =
sizeof(abc) /
sizeof(abc[0]);
int
a, b;
Func(abc, length,15, a, b);
getchar();
return
0;
}