It looks to me like you are taking an input array of
int and converting it into two output arrays: the first with the actual
int values in the input array, and the second with a frequency count for each corresponding value in the first.
To do this, you will need a way to search the array to see if it contains the given number. If it does not, add it to the output arrays with a frequency of one. If it does, simply bump the frequency count.
For example, given an input array of
2, 7, -3, 7, 42, ...
what you need to do is, for each value in the input array, check to see if it is already in the output array. You'll need to keep track of the used size of the output arrays.
1 2 3
|
int output_used_size = 0;
int output_values[ MAX_SIZE ];
int output_frequencies[ MAX_SIZE ];
|
Since 2 is not in output_values[], we'll need to add it.
output_used_size --> 1
output_values --> 2
output_frequencies --> 1
The next input value is 7. It also is not in the output array, so we'll add it too:
output_used_size --> 2
output_values --> 2, 7
output_frequencies --> 1, 1
Likewise with -3:
output_used_size --> 3
output_values --> 2, 7, -3
output_frequencies --> 1, 1, 1
This next time we have a 7 again. Since it is already in the array, we'll just bump the frequency counter:
output_used_size --> 3
output_values --> 2, 7, -3
output_frequencies --> 1, 2, 1
Continuing, we try to find 42 in the output array. Since it is not there, we'll have to add it:
output_used_size --> 4
output_values --> 2, 7, -3, 42
output_frequencies --> 1, 2, 1, 1
And so on.
Hope this helps.