//找出数组中三个数相加为0,返回存在的组数
//输入指正*A,长度为size,返回*B和长度num
int threeSum_0(int *A,int size,int *B,int &num)
{
vector<int> temp(A, A + size); //使用vector操作数据
sort(temp.begin(),temp.end());//sort
//夹逼
auto last = temp.end();
int *p = new int[];//p为临时数组,大小自己设置
for (auto a = temp.begin(); a <prev(last,); a++){
auto b = next(a);
auto c = prev(last);
while (b < c){
if (*a + *b + *c > )
--c;
else if (*a + *b + *c < )
++b;
else{
*(p++) = *a;
*(p++) = *b;
*(p++) = *c;
num = num + ;
++b;
--c;
}
}
}
p = p - num;
for (int i = ; i < num; i++)
B[i] = p[i];
delete[] p;
return num/; //符合条件的组数
}