exo1.c: fix a typo
[TD_C.git] / exo1 / exo1.c
index 8b44ea40af1f93a0284ade71122312c3a0dcd4ea..34251200207f6ef3afc6bc66f9f8e307ca55918f 100644 (file)
@@ -7,7 +7,7 @@ void promptValue(int* addr) {
     scanf("%d", addr);
 }
 
-// The efficience of this swap alternative is debatable ..
+// The efficiency of this swap alternative is debatable ..
 void xorSwap (int *v1, int *v2) {
     if (v1 != v2) {
         *v1 ^= *v2;
@@ -32,11 +32,13 @@ void displayArray(int* array, int count) {
 
 bool sortFirst(int* array, int length) {
     bool rt = false;
+    // This loop could probably be replaced by a while loop with conditions
+    // on the array values permutation AND the iteration value, later ...
     for (int i = 0; i < length-1; i++) {
         if (array[i] > array[i+1]) {
             swap(&array[i], &array[i+1]);
             //xorSwap(&array[i], &array[i+1]);
-            rt = true;
+            if (!rt) { rt = true; };
         }
     }
     return rt;