0

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

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by bmaglar
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.