Comparing all elements of an array

For a program that I am writing for fun (one that finds the Highest Common Factor and the Lowest Common Multiple for you); I've come across some difficulty.

I have two arrays that contain 14 numbers. To find the Lowest Common Multiple of all the numbers, I need to compare every element in each array. So far I've got this test:

for(int i = 0; i < C_I_14; i++)
{

    for(int j = 0; j < C_I_14; j++)
    {
        if(array[i] == arr[j])
        {
            tesst[i] = array[i];
        }
    }

}

(where C_I_14 = 14)

The thing is, there are endless amounts of things that could go wrong with: tesst[i] = array[i]

So, can anyone help me sort out my little algorithm?

Answers


Sort each of your input arrays, then get the intersection using std::set_intersection.



Need Your Help

Github redirect from sign-out to sign-in page instead of homepage

javascript jquery github greasemonkey userscripts

I would to redirect to sign-in page when sign-out instead of redirect to homepage in github.

Datepicker Value change windows phone 8

c# xaml windows-phone-7 windows-phone-8 datepicker

I navigated to a page where I want to be able to see the date i got from the Database and to edit that date if it is needed. When I change the date, it always go back to the date that was set by the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.