repositories
/
TD_C.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f81720f
)
sortFirst(): only change the return value once, not at every iteration
author
Jérôme Benoit
<jerome.benoit@piment-noir.org>
Tue, 14 Feb 2017 21:50:42 +0000
(22:50 +0100)
committer
Jérôme Benoit
<jerome.benoit@piment-noir.org>
Tue, 14 Feb 2017 21:50:42 +0000
(22:50 +0100)
when a permutation is done.
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
exo1/exo1.c
patch
|
blob
|
blame
|
history
diff --git
a/exo1/exo1.c
b/exo1/exo1.c
index 8b44ea40af1f93a0284ade71122312c3a0dcd4ea..b4bf35d1dc84937bd00dc20f21d7b73029b4873f 100644
(file)
--- a/
exo1/exo1.c
+++ b/
exo1/exo1.c
@@
-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;