// Contoh Bab 07: mengurutkan array dan vector. // // Compile: g++ -std=c++17 -O2 -o urut exercises/07/06-urut.cpp // Jalankan: ./urut #include #include #include using namespace std; int main() { int a[5] = {5, 2, 9, 1, 7}; sort(a, a + 5); for (int i = 0; i < 5; i++) cout << a[i] << " "; cout << "\n"; vector v = {5, 2, 9, 1, 7}; sort(v.begin(), v.end()); for (int x : v) cout << x << " "; cout << "\n"; sort(v.begin(), v.end(), greater()); for (int x : v) cout << x << " "; cout << "\n"; return 0; }