Hi
I have two array sorting functions, bubbleSort and selectionSort. They both sort an array and returns the number swap operations made during the sorting.
When I try to output the result I'm getting a funny problem. When I do this:
int first = selectionSort(array, SIZE);
int second = bubbleSort(array2, SIZE);
cout << "Selection sort iterations: " << first << endl;
cout << "Bubble sort iterations: " << second << endl;
Ok, I solved the problem by changing the order of the expressions to
1 2 3 4
int first = selectionSort(array, SIZE);
cout << "Selection sort iterations: " << first << endl;
int second = bubbleSort(array2, SIZE);
cout << "Bubble sort iterations: " << second << endl;
With this order the output is correct.
But isn't this really strange? Could it be a bug in the compiler?