X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TP_13%2Fexo1%2Flib%2Fsort.c;h=01a742f7966d557ff7724409bbfa2f9e4fa48ce2;hb=475ee86d70921638c700bc0934441c7fe2c905d1;hp=70a766b505773ba6e14823aef9b194c9c55c0b95;hpb=c944d83b743f75264d017b47bc388962c51f2d3e;p=TD_C.git diff --git a/TP_13/exo1/lib/sort.c b/TP_13/exo1/lib/sort.c index 70a766b..01a742f 100644 --- a/TP_13/exo1/lib/sort.c +++ b/TP_13/exo1/lib/sort.c @@ -10,11 +10,13 @@ bool descending(int a, int b) { } bool ascending_and_even(int a, int b) { - return (ascending(a, b) && (a % 2 == 0)); + return (((a % 2 != 0) && (b % 2 == 0)) || ((a % 2 == 0) && (b % 2 == 0) && ascending(a, b)) \ + || ((a % 2 != 0) && (b % 2 != 0) && ascending(a, b))); } bool ascending_and_odd(int a, int b) { - return (ascending(a, b) && (a % 2 != 0)); + return (((a % 2 == 0) && (b % 2 != 0)) || ((a % 2 == 0) && (b % 2 == 0) && ascending(a, b)) \ + || ((a % 2 != 0) && (b % 2 != 0) && ascending(a, b))); } static bool sort_first(int* array, unsigned length, criteria_cb criteria) { @@ -28,7 +30,7 @@ static bool sort_first(int* array, unsigned length, criteria_cb criteria) { return rt; } -/* this function is awaited in the array.c file */ +/* the feature of this function is awaited in the array.c file */ void sort_bubble_array(int* array, unsigned length, criteria_cb criteria) { bool rt; do {