hi, I dont know how to use bubble sort or heap or whatever else there is.

what im trying to do is sort a list of number and delete the repeats.

So the user types in how many numbers they want to enter, and then types in the numbers.

ex. i want to enter 5 numbers.
numb1. 9
numb2. 9
numb3. 1
numb4. 3
numb5. 1

then a list is printed like the following
first column is the numbers in descending order, with the count next to them.

9 2
3 1
1 2

heres what i got can i get code for sorting and completing the last part.

#include <iostream>
using namespace std;



int main(){
    
int numb;

cout<<"How many numbers do you want to enter(1-50): ";
cin>>numb;    

int array[numb];
for(int x=1;x<=numb;x++){
cout<<"Enter number "<<x<<": ";
cin>>array[x];               
}    

int count[numb];

for(int h=1;h<=numb;h++){
count[h]=0;        
}


for(int y=1;y<=numb;y++){

for(int u=1;u<=numb;u++){
if(array[y]==array[u]){                   
count[y]+=1;
}            
}
}                        
 
 
for(int a=1;a<=numb;a++){
cout<<array[a]<<" "<<count[a]<<endl;        
}
 
        
    
system("pause");    
}

What is the problem? What is the current output? Are there any compiler errors?

What is the problem? What is the current output? Are there any compiler errors?

using the example above
numb1. 9
numb2. 9
numb3. 1
numb4. 3
numb5. 1

the output would be
9 2
9 2
1 2
1 2
3 1

it needs to be
9 2
3 1
1 2

for any case

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.