forked from Bhupesh-V/30-seconds-of-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsort.cpp
More file actions
35 lines (26 loc) · 714 Bytes
/
Copy pathsort.cpp
File metadata and controls
35 lines (26 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
Author : Italo Vinicius
Date : 01/10/2019
Time : 21:00
Description : Returns a ordered vector in increasing or decreasing order.
*/
#include <iostream>
#include <algorithm>
#include <vector>
int main() {
// create a vector of 10 integers
std::vector<int> v {-1,0,4,-5,12,2,10,-11,3,5};
// display the vector in incresing order with sort;
std::sort(v.begin(), v.end());
for (int i = 0 ; i < 10; i++) {
std::cout << v[i] << " ";
}
std::cout << std::endl;
// display the vector in decresing order with sort;
sort(v.begin(), v.end(), std::greater<int>());
for (int i = 0 ; i < 10; i++) {
std::cout << v[i] << " ";
}
std::cout << std::endl;
return 0;
}