-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsortarray.cpp
46 lines (34 loc) · 886 Bytes
/
sortarray.cpp
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
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <array>
#include <algorithm>
using namespace std;
const int BatasArray = 9;
void displayarray (array <int, BatasArray> &angka);
void displayarray (array <char, BatasArray> &huruf );
int main () {
array <int, BatasArray> angka = {9,7,1,2,4,3,8,6,5};
array <char, BatasArray> huruf = {'i','b','a','e','c','h','d','f','g'};
displayarray (angka);
displayarray (huruf);
cout <<"Diurutkan menjadi : "<<endl;
sort (angka.begin(), angka.end());
displayarray (angka);
sort (huruf.begin(), huruf.end());
displayarray (huruf);
cin.get();
return 0;
}
void displayarray (array <int, BatasArray> &angka){
cout <<" Array Angka: ";
for ( int &a : angka ) {
cout << a <<" ";
}
cout <<"\n";
}
void displayarray (array <char, BatasArray> &huruf ) {
cout <<" Array Huruf: ";
for ( char &b : huruf ) {
cout << b <<" ";
}
cout <<"\n";
}