How to find the intersection of two arrays in C language?
To find the intersection of two arrays, you can use two loops to iterate through the arrays, checking if the elements are equal and adding them to the intersection if they are.
Here is an example code implemented in C language:
#include <stdio.h>
void intersection(int arr1[], int arr2[], int size1, int size2) {
    int i, j;
    for (i = 0; i < size1; i++) {
        for (j = 0; j < size2; j++) {
            if (arr1[i] == arr2[j]) {
                printf("%d ", arr1[i]);
                break;
            }
        }
    }
}
int main() {
    int arr1[] = {1, 2, 3, 4, 5};
    int arr2[] = {4, 5, 6, 7, 8};
    int size1 = sizeof(arr1) / sizeof(int);
    int size2 = sizeof(arr2) / sizeof(int);
    printf("交集为:");
    intersection(arr1, arr2, size1, size2);
    return 0;
}
When running the above code, the output will be:
交集为:4 5
In this example, we define two arrays, arr1 and arr2, representing two arrays. We then call the intersection function, passing in arr1, arr2, as well as the sizes of the two arrays, size1 and size2. Within the intersection function, two loops are used to iterate through the arrays and check if the elements are equal. If they are, they are printed out.