0
Location of elements of one array in another array?
Hello. I need a help. We have two arrays arr1[] = {11,11,11,1,18,14,14,9,9} and arr2[] = {1,9,9,11,11,11,14,14,18}. I need to find all indexes of elements of array arr2 in arr1!
1 Antwort
+ 1
If you want to use a library function, it probably is in C++ STL, but I don't know it.
If you want to make your own function, then you need 2 for loops: one to take each value in arr2[i], and one to compare value of arr2[i] == arr1[j]. Save all j values in a matrix.
Attention!!! You have duplicates values in arr2, so first you need to exclude duplicates values: if arr[i] == arr[i+1] then...