Home > Back-end >  College students, in the hope that we help solve a program, thank you! Beginners.
College students, in the hope that we help solve a program, thank you! Beginners.

Time:09-29

With a return value of function and use an array as a function parameter
In-class practice known two integer arrays [10], a [10] and b write a using array as parameter of function, the function to find whether there is a same element in the array a and b, the return value is a elements found in the same address, if not found, it returns NULL,

CodePudding user response:

Use the map

Int * FindSame (int * a, int size_a, int * b, int size_b)
{
Map Mark;
int i;

For (I=0; I & lt; Size_a; I++)
{
Mark [b] [I]=true;
}

For (I=0; I & lt; Size_a; I++)
{
If (mark. The find (a [I])!=mark. The end ())
Return & amp; A, [I].
}

return NULL;
}
  • Related