I am a student of electronics and i have to do a homework in C++. The problem is the following: how to write a code in order to find the most frequent value of two different one dimension arrays. the first array has for example 10 elements and the second array 20 elements. Could someone can help me? thank you

create a structure that will keep track of the frequencies

class freq
{
public:
    freq() {value = quantity = 0;}

    int value;
    int quantity;
};

Then an array of those structures -- since you need two arrays with a total of 30 elements then you will need at most an array of 30 structures struct freq[30]; now just iterate through each array. For each element in the array search that array of structures. If the value is found then just increment quantity; If value was not found then just use the first unused element.

I'm not going to code this for you, but it should give you an idea of what your program needs to do.

Thank you! i think i can cope with it now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.