repositories
/
TD_C.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TP 13 exo1: Implement more asked features and test them
[TD_C.git]
/
TP_13
/
exo1
/
lib
/
sort.c
diff --git
a/TP_13/exo1/lib/sort.c
b/TP_13/exo1/lib/sort.c
index 0fdb0be30c6ef0c087d8088dc2f3afdc0c0ca18d..f8917ea5ab6987bb96ccc9909f5bbdfa6f0d1cb8 100644
(file)
--- 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) {
}
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) {
}
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) {
}
static bool sort_first(int* array, unsigned length, criteria_cb criteria) {
@@
-22,7
+24,7
@@
static bool sort_first(int* array, unsigned length, criteria_cb criteria) {
for (unsigned i = 0; i < length-1; i++) {
if (criteria(array[i], array[i+1])) {
swap_int(&array[i], &array[i+1]);
for (unsigned i = 0; i < length-1; i++) {
if (criteria(array[i], array[i+1])) {
swap_int(&array[i], &array[i+1]);
-
if (!rt) { rt = true; }
;
+
rt = true
;
}
}
return rt;
}
}
return rt;