#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
int *array_diff(const int *arr1, size_t n1, const int *arr2, size_t n2, size_t *z)
{
int *target = (int *)malloc( 100 * sizeof(int) ), i, j, cnt = 0;
bool f1[n1], f2[n2];
for( i = 0; i < n1; i++ )
f1[i] = 1;
for( j = 0; j < n2; j++ )
f2[j] = 1;
for( i = 0; i < n2; i++ )
for( j = 0; j < n1; j++ )
if( arr2[i] == arr1[j] ) f1[j] = 0;
for( i = 0; i < n1; i++ )
{
if( f1[i] )
{
target[cnt] = arr1[i];
cnt++;
}
}
*z = cnt;
return target;
}
06-08
10-21
07-20
07-20
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交