#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# array problem

Member Posts: 5
how would i display two different array with random numbers using these parameters
void displayArray(const int*, int);

and also how would i find the numbers that are equal in both arrays using
int * intersection(const int * const, int, const int* const, int, int &);
if anybody has any ideas that would be very helpful thanks

• Member Posts: 6,519
[b][red]This message was edited by AsmGuru62 at 2002-9-18 8:43:15[/red][/b][hr]
: how would i display two different array with random numbers using these parameters
: void displayArray(const int*, int);
:
: and also how would i find the numbers that are equal in both arrays using
: int * intersection(const int * const, int, const int* const, int, int &);
: if anybody has any ideas that would be very helpful thanks
:
[blue]You need three arrays actually, two parameters and a result array. Basically, here is an algorithm:

1. Get the value from the first array
2. Use [b]for()[/b] to scan the second array to find that value
3. If value is found, store it into result array
4. Repeat #1 until no more values is found in the first array

Now, when you storing into result array you may want to make sure there is no duplicate items there, so check for that too.

Basically, it will be two nested [b]for()[/b] statements. Three - if you decide to look for duplicates.[/blue]

• USAMember Posts: 4,496 ✭✭

____ // http://forcoder.org // free video tutorials and ebooks about ( Scratch C++ PL/SQL Swift R C Go Perl Python Ruby Visual Basic .NET Java PHP Objective-C Delphi Visual Basic Assembly JavaScript MATLAB C# F# SAS Bash Awk Transact-SQL Alice ML Hack FoxPro ABAP Clojure Scheme Julia LabVIEW Lisp Erlang Rust VBScript Lua Scala Kotlin COBOL Crystal Fortran Dart Prolog Logo Ada D Apex ) _______