C++
x
28
1
2
3
using namespace std;4
void Exchange(int* a, int* b) {5
int var;6
var = *a; //For swapping or exchanging values. O_o7
*a = *b;8
*b = var;9
}10
void Algorithm(int array[], int nerd) {11
std::sort(array, array + nerd);12
}13
int main() {14
int n, i;15
cout << "\nEnter the count of numbers for the algorithm: ";16
cin >> n;17
int arr[10];18
for (i = 0; i < n; i++) {19
cout << "Enter number " << i + 1 << ": ";20
cin >> arr[i];21
}22
Algorithm(arr, n);23
cout << "\nFinal Data you entered (after the algorithm performed)";24
for (i = 0; i < n; i++)25
cout << " -> " << arr[i];26
return 0;27
}28
$ g++ prog.cc -Wall -Wextra -std=c++11 -pedantic
Stdin
5 1 4 2 9 3Start
Enter the count of numbers for the algorithm: Enter number 1: Enter number 2: Enter number 3: Enter number 4: Enter number 5: Final Data you entered (after the algorithm performed) -> 1 -> 2 -> 3 -> 4 -> 9
0
Finish