All pastes #2047314 Raw Edit

Untitled

public text v1 · immutable
#2047314 ·published 2011-04-17 00:54 UTC
rendered paste body
int ints_intersect(int *a, int n, int *z, int x)
{
	int i=0;
	int j=0;
	int k=0;
	int result=n;
	while (i<result && j<x)
	{
		if (z[j]>a[i])
		{
			k=i;
			while(k<result)
			{
				a[k]=a[k+1];
				k++;
			}
			result--;
		}
		else if (z[j]<a[i])
		{
			j++;
		}
		else
		{
			i++;
			j++;
		}
	}
	while (i<result && j==x)
	{
		k=i;
		while(k<result)
		{
			a[k]=a[k+1];
			k++;
		}
		result--;
	}
	return result;	
}