ok well I wasn't really grasping the map issue mostly cause all the examples online never did it for ints and ints. So I tried to go with something else.
Here is what I got:
Code:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> aVector;
int count[999];
int x;
cout << "Number of integers you wish to enter: " << endl;
cin >> x;
aVector.resize (x);
cout << "Enter " << x << " integer(s) between 0-100: " << endl;
for (int i = 0; i < x; i++)
{
cin >> aVector[i];
}
cout << "----------------sort" << endl;
sort(aVector.begin(), aVector.begin()+x);
for ( int i = 0; i < x; i++)
{
cout << aVector[i] << endl;
count[aVector[i]]++;
}
cout << "----------------Counting" << endl;
for (int i = 0; i < aVector.size(); i++)
{
cout << count[i] << endl;
}
remove(count, count + x, 0);
cout << "---------------Unique" << endl;
aVector.erase(unique(aVector.begin(), aVector.end()), aVector.end());
for ( int i = 0; i < aVector.size(); i++)
{
cout << aVector[i] << endl;
}
return 0;
}
My issue lies within this statement:
Code:
for (int i = 0; i < aVector.size(); i++)
{
cout << count[i] << endl;
}
remove(count, count + x, 0);
My problem is, is that it counts EVERY number from 0 on. You'll see if you run it. I tried to remove the 0s but it didnt work. Any help?