You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// comparator is used to reverse the array instead of using reverse function
// comparetor whic is in build and this in build func is pass as a parameter in any function therefore we don't use any () to call it
bool compare(int a, int b)
{
return a > b;
}
*/
int main()
{
int arr[] = {-2, 3, 4, -1, 5, -12, 6, 1, 3};
int n = sizeof(arr) / sizeof(int);
/*
// here we call the comaretor function within the sort function therefore we pass as a parameter and therefore the result will be the reverse of sorted element
sort(arr, arr+n, compare);
for(int i=0; i<n; i++){
cout<<arr[i]<<" ,";
}
*/
/*
// greater<int>() is used to arrange the element in decreasing order this is also pass as parameter within function