#include <stdlib.h>
#include <stdio.h>
int DeleteSame(int *array1,int n1,int *array2,int n2)
{
int i,j;
int sameLength=0;
i=j=0;
while(i<n1&&j<n2)
{
if(array1[i]==array2[j])
{
sameLength++;
array1[i]=-1;
array1[j]=-1;
i++;
j++;
}
else if(array1[i]<array2[j])
{
i++;
}
else
{
j++;
}
}
return sameLength;
}
int main()
{
int a[10]={0,1,2,3,4,5,6,7,8,9};
int b[8]={3,5,7,8,10,15,17,18};
printf("%d\n",DeleteSame(a,10,b,8));
return 1;
}
#include <stdio.h>
int DeleteSame(int *array1,int n1,int *array2,int n2)
{
int i,j;
int sameLength=0;
i=j=0;
while(i<n1&&j<n2)
{
if(array1[i]==array2[j])
{
sameLength++;
array1[i]=-1;
array1[j]=-1;
i++;
j++;
}
else if(array1[i]<array2[j])
{
i++;
}
else
{
j++;
}
}
return sameLength;
}
int main()
{
int a[10]={0,1,2,3,4,5,6,7,8,9};
int b[8]={3,5,7,8,10,15,17,18};
printf("%d\n",DeleteSame(a,10,b,8));
return 1;
}