definition:
reverse for C ++, all elements of a given section are sorted, a reverse function, does not have the sorting function. C ++ Standard Library of the sort function is included in the header file #include <algorithm> of.
grammar:
reverse(first,last)
parameter:
(1) first indicates the start address of the array to be sorted;
(2) at one end of the array represents the Last address;
Features:
reverse functions used in C ++, all elements of a given section is inverted, generally is a direct inversion of the array, for example, the array a [10] reverse, reverse (a, a + 10). Somewhat similar to the sort (start, end, cmp).
example:
N sets of data to descending order
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int a[n]; for(int i=0;i<n;i++) { cin>>a[i]; } sort(a,a+n); reverse(a,a+n); for(int i=0;i<n-1;i++) { cout<<a[i]<<" "; } cout<<a[n-1]; }