4 void swap(int* v1
, int* v2
) {
10 /** Display the array on standard output. */
11 void displayArray(int* array
, int count
) {
12 for (int tabIndex
= 0; tabIndex
< count
; ++tabIndex
) {
13 printf("array[%d] = %d\n", tabIndex
, *(array
++));
17 /** Swap every out-of-order cells at most once.
19 * @return true if a swap was performed, false if the whole array is ordered.
21 bool sortFirst(int* array
, int length
) {
22 bool swappedValues
= false;
26 if (*cursor
> *(cursor
+ 1)) {
27 swap(cursor
, cursor
+ 1);
37 void sortArray(int* array
, int length
) {
38 while (sortFirst(array
, length
));
41 /** Fill the array with user input. */
42 void promptArray(int* array
, int length
) {
43 for (int tabIndex
= 0; tabIndex
< length
; ++tabIndex
) {
44 printf("Enter value for index %d:\n", tabIndex
);
53 displayArray(arr
, 10);