One possibility would be to write the input data into a vector
vector <int> mdat = { 7, 5, 7, 4, 1, 5, 6, 1 };
And manage the histogram as a result in a pair:
vector <pair<int, int>> hist;
Then it is possible to loop through the vector mdat and use it with
a find_if() query to check if the current value is already contained.
If it is not contained you can append the value as a new pair:
hist.push_back(make_pair(val, 1));
If it is already included, you can simply increment the second value.