Search
 
SCRIPT & CODE EXAMPLE
 

CPP

sort function from bigest to smallest c++

// C++ program to demonstrate descending order sort using
// greater<>().
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int arr[] = { 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
    int n = sizeof(arr) / sizeof(arr[0]);
 
    sort(arr, arr + n, greater<int>());
 
    cout << "Array after sorting : 
";
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
 
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ competitive programming mst 
Cpp :: how to run a c++ program in the background 
Cpp :: c++ rand 
Cpp :: c++ code for selection sort 
Cpp :: C++ Multi-line comments 
Cpp :: calling struct to a struct c++ 
Cpp :: c++ array loop 
Cpp :: default access modifier in c++ 
Cpp :: how to check size of file in c++ 
Cpp :: vector to string c++ 
Cpp :: difference between lower and upper bound 
Cpp :: max function in c++ 
Cpp :: c++ string comparison 
Cpp :: c++ type casting 
Cpp :: C++ Find the sum of first n Natural Numbers 
Cpp :: define unicode c++ 
Cpp :: print all elements of vector c++ 
Cpp :: how to change a value from an array c++ 
Cpp :: c++ init multidimensional vector 
Cpp :: how to take space separated input in c++ 
Cpp :: minimum value in array using c++ 
Cpp :: count bits c++ 
Cpp :: how to create a vector in c++ 
Cpp :: what is c++ used for 
Cpp :: c++ fstream 
Cpp :: how to code string to int converter c++ 
Cpp :: sqrt in c++ 
Cpp :: push local branch to another remote branch 
Cpp :: c++ insert into map 
Cpp :: cpp mutex 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =