How do you count repeated numbers in an array?!

So I already gave this a go and will post my code below. The question is about the last loop before the program cout's. i thought the count would keep track of the repeated numbers so i could display them but it does not. pleas help in any way possible. I italicized the loop i am referring to. or at least i tried to xD




#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int inputs[30];
int numofloops;
int maxvalue = inputs[0];
int temp = -1;
int count = 0;
int unique[30];
int check;







cout << "how many input values [max: 30]?" << endl;
cin >> numofloops;

cout << "Enter " << numofloops << " numbers." << endl;
for (int k = 0; k < numofloops; k++)
{
cin >> inputs[k];
}

for (int i = 0; i < numofloops; i++)
{
if (inputs > maxvalue)
{
maxvalue = inputs[i];
}

}

int n = numofloops;
int * Numcounts = new int[n];

cout << "Largest Number: " << maxvalue << endl;

for (int i = 0; i < numofloops - 1; i++)
{
for (int i = 0; i < numofloops - 1; i++)
{
if (inputs[i] > inputs[i + 1])
{
temp = inputs[i];
inputs[i] = inputs[i + 1];
inputs[i + 1] = temp;
}

}

}

int number = 0;
for (int k = 0; k < numofloops; ++k)
{
short sv = inputs[k];
short event_flag = 0;
for (int i = 0; i < number; ++i)
{
if (sv == unique[i])
{
event_flag = 1;
break;
}
}

if (event_flag == 0)
{
unique[number] = sv;
++number;
}



}



[i]for (int i = 0; i < numofloops; i++)
{
for (int j = 0; j < numofloops; j++)
{
if (inputs[j] == unique[j])
{

count++;
}


}
count = 0;
}





for (int i = 0; i < number; i++)
{
cout << unique[i] << setw(10) << count << endl;


}




cout << endl;




system("PAUSE");
return 0;
}


Topic archived. No new replies allowed.