Tuesday, May 17, 2011

Intersection of two sets

public class arraydemointersect
{

static void intersect(int x[],int y[])
{
int i,j,k=0,z[];
z=new int[5];
for(i=0;i {
for(j=0;j {
if (x[i]==y[j]&&x[i]!=z[j])
{
z[k]=x[i];
System.out.println(z[k]);
k++;
}
}
}
}

public static void main(String[] args)
{
intersect(new int[] {44,22,77,55,22,33},new int[]{22,59,64,77});
}

}

No comments: