代码:
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 15;
int n[maxn] = {1,5,2,4,1,3,2,3,5,1};
bool cmp(int i,int j){
return i>j;
}
void OUTPUT(){
for(int i=0;i<10;i++)
cout<<n[i]<<'\t';
cout<<endl;
return ;
}
int main(){
sort(n,n+10,cmp);
OUTPUT();
sort(n,n+10);
OUTPUT();
swap(n[0],n[9]);
OUTPUT();
swap(n[0],n[9]);
int range = unique(n,n+10) - n;
OUTPUT(); cout<<range<<endl;
int l = lower_bound(n,n+10,3) - n;
int r = upper_bound(n,n+10,3) - n;
cout<<l<<'\t'<<r<<endl;
return 0;
}