X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TP_7%2Fexo1%2Fexo1.c;h=6509b0635333c8196cc7540b67f888bd9ab6c8c3;hb=2f54ac48ef2c4ab4e87426c2bf89b9f5eef7008b;hp=b57e2ac794b94aa56b6209d46d1a23b852f724cf;hpb=b10f2dc98106b52e190abb4041be21880b2a391c;p=TD_C.git diff --git a/TP_7/exo1/exo1.c b/TP_7/exo1/exo1.c index b57e2ac..6509b06 100644 --- a/TP_7/exo1/exo1.c +++ b/TP_7/exo1/exo1.c @@ -17,11 +17,9 @@ void xorSwap (int *v1, int *v2) { } void swap(int* v1, int* v2) { - if (v1 != v2) { - int tmp = *v1; - *v1 = *v2; - *v2 = tmp; - } + int tmp = *v1; + *v1 = *v2; + *v2 = tmp; } void displayArray(int* array, int count) { @@ -49,7 +47,6 @@ void sortArray(int* array, int length) { do { rt = sortFirst(array, length); } while (rt); - } int main() { @@ -72,8 +69,8 @@ int main() { printf("\nView array content unsorted:\n"); displayArray(tab, tab_length); - sortArray(tab, tab_length); printf("\nNow, sorting the array...\n"); + sortArray(tab, tab_length); printf("\nView array content sorted:\n"); displayArray(tab, tab_length);