Originally Posted by
erag
somebody?
Code:
#include <stdio.h>
#define a_size 6
#define b_size 8
int function(int array_a[], int lenght_a, int array_b[], int lenght_b);
int main()
{
int a[a_size] = { 4, 5, 2, 1, 2, 3 };
int b[b_size] = { 9, 8, 8, 7, 8, 8, 2, 3 };
int result = function(a, a_size, b, b_size);
printf("%d\n", result);
return 0;
}
int function(int array_a[], int lenght_a, int array_b[], int lenght_b)
{
int i, j, count = 0, hold = 0;
for(i = 0; i < a_size; i++) {
for(j = 0; j < b_size; j++) {
if((array_b[j] == array_a[i])&&(array_b[j] != hold)) {
count++;
hold = array_b[j];
}
}
}
return count;
}
This should work