Sorting a number

Suppose 9 numbers are stored in a variable

1
2
3
4
5
6
7
8
9
10
11
double numbers[9]={ 222456 ,
                           424562 ,
                           525462 ,
                           622345 ,
                           722666 ,
                           823422 ,
                           562252 ,
                           522225 ,
                           722252 },number,sorted_number[10];
cout<<"Enter a number : "
cin>>number


and after the user enters the number then it sort that entered and 9 numbers in decending order and store them in sorted_number
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
#include <algorithm>
#include <functional>

//...
int main()
{
//Your code...
    std::copy(number, number + 9, sorted_number);
    sorted_number[9] = number;
    std::sort(sorted_number, sorted_number +  10, std::greater<double>());
//Other code...
}
Topic archived. No new replies allowed.