Code:
void FindPair(float a[], int n, int position[],int& num)
{
	float min=abs(a[0]-a[1]);
	for(int i=0;i<n;++i)
	{
		for(int j=i+1;j<n;++j)
			if(min>abs(a[i]-a[j]))
				min=abs(a[i]-a[j]);
	}
	
	int k=0;
	num=0;
	for(int i=0;i<n;++i)
	{
		for(int j=i+1;j<n;++j)
			if(min==abs(a[i]-a[j]))
			{
				position[k]=i;
				position[k+1]=j;
				++num;
				k+=2;
			}
	}
	cout<<endl;
	cout<<"Danh sach vi tri cac cap thoa dieu kien: "<<endl;
	for(int i=0;i<k;++i)
	{
		cout<<position[i]<<" ";
	}
	cout<<"\n So luong cap thoa dieu kien: "<<num;
}
các bạn xem thử nha!!!!!!!!!!!!!!!hihi