i have this program and i need to count how many times each number is repeated and then delete the repeated i dont how to count them and then delete them can someone help??
#include <iostream>
using namespace std;
struct node
{
int item;
node *next;
};
struct node *push_front ( node *cur, int item )
{
node *p = new node;
p->item = item;
p->next = cur;
cur = p;
return cur;
}
int main()
{
node *cur = 0;
node *save;
for ( int i = 0; i < 10; i++ )
cur = push_front ( cur, rand() % 5 + 1 );
while ( cur != 0 )
{
save = cur->next;
cout<< cur->item <<' ';
delete cur;
cur = save;
}
cout<<'\n';
}