From cc95ca868f47316d04bf186f0dace4a82dad10a5 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Mon, 24 Feb 2025 13:54:10 +0100 Subject: [PATCH] First atempt to binary sort --- cmake-build-debug/.ninja_deps | Bin 6872 -> 2584 bytes cmake-build-debug/.ninja_log | 20 ++---------------- .../Testing/Temporary/LastTest.log | 4 ++-- main.c | 19 ++++++++++++++--- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/cmake-build-debug/.ninja_deps b/cmake-build-debug/.ninja_deps index ab92083b82221463c3e259a37c8de336926aca67..b9347fd6c2ebd23a5d282b5f4fdd5dc1e0ba3186 100644 GIT binary patch delta 355 zcmca%Izwc`7M96J7zHQK<=|#~JozGrEO%N?VtTP&1_J}bBOqU$@!{lyj3SeHIk_1h zO#a9vKiPtlhw(m$#haXypPZeU5?=yTeQ$Chr#j-ulaUE!!1*<7e%}GrL*~@SRs79OdGT34pZXU)P0r`$WWD(R|9^wYirmtZ zKQOaTp3lw8cmeDnIUXKny^QlfbyAbxbBi*b1F|G1%khXYo&~e~fUGlMm32IPjHkhF zsN-Ruyq1TX@f0{P&H`B{K`MlbOHy(&lXTN^@)LosIRUhB@*Bw-RvBRE$xe0@$OZrz C1$;pO delta 920 zcmbOsa>I1P78bq=28IR(Ab6+eap|huWGl`*MxBX*G9s=OsYS_|$*D$q$$I$=43Gc+ z|L-u-)S|ATHR1l`{+wFLP{FOqjGQu) zIoY@wZ%#hQC^A_S$htAvkWq579~&3rb)XIqi;XicwHR#pwaJZa%8XZm#!61!$0o#h zW%5NJ|1wwyA3GQ0C7_J_WD9m4#)}{pZ+v`lW_odI3CP9^lMC7P8P88%$ZpJd4s7x} zc0R_llP@w$O%~@6Wjq69Nlt#p&cm&nSd^Rr_Tp)H<0+s^r6*tDV4b{{gPrjt z*ahb}gcwgue#jxucpNCJE_4hSFE60c8ruI|up1nTlQ(c?h*c$k#$(Ee?AgeKCUo7uW=Ef=eJ@$nhA5Pio49>H` zIA!;moaBwdDSPpk)x8*;vT=NR7fNx;p69NeR*qBl^+tvGYMip(ynn4*V6q&ru$rvH KSpy0lxBvi4iUj%q diff --git a/cmake-build-debug/.ninja_log b/cmake-build-debug/.ninja_log index 0e4d746..d0cd88e 100644 --- a/cmake-build-debug/.ninja_log +++ b/cmake-build-debug/.ninja_log @@ -1,21 +1,5 @@ # ninja log v6 1 9 1740394573852693968 CMakeFiles/Exercices.dir/Exercice2.c.o 8abbf7ed2ff63668 -14 23 1740399424068673015 Exercices f05032c4fac3334d -0 14 1740399424054672910 CMakeFiles/Exercices.dir/main.c.o 30c179a7aefe8551 -0 9 1740399723326817334 build.ninja 2e74603cecdb425f -0 14 1740399723328817343 CMakeFiles/Exercices.dir/main.c.o 30c179a7aefe8551 -14 23 1740399723342817403 Exercices 1155f81bcff01d1c -0 13 1740399750185932613 CMakeFiles/Exercices.dir/main.c.o 30c179a7aefe8551 -13 26 1740399750198932669 Exercices 1155f81bcff01d1c -1 14 1740399762272984410 CMakeFiles/Exercices.dir/main.c.o 30c179a7aefe8551 -14 22 1740399762285984465 Exercices 1155f81bcff01d1c -0 17 1740399869408438810 CMakeFiles/Exercices.dir/main.c.o 30c179a7aefe8551 -17 26 1740399869424438878 Exercices 1155f81bcff01d1c -0 14 1740399877033471575 CMakeFiles/Exercices.dir/main.c.o 30c179a7aefe8551 -14 23 1740399877047471635 Exercices 1155f81bcff01d1c -1 17 1740399893282541545 CMakeFiles/Exercices.dir/main.c.o 30c179a7aefe8551 -17 32 1740399893298541615 Exercices 1155f81bcff01d1c -0 14 1740399931349708754 CMakeFiles/Exercices.dir/main.c.o 30c179a7aefe8551 -14 22 1740399931363708815 Exercices 1155f81bcff01d1c -0 16 1740399978792913976 CMakeFiles/Exercices.dir/main.c.o 30c179a7aefe8551 16 25 1740399978808914044 Exercices 1155f81bcff01d1c +0 16 1740399978792913976 CMakeFiles/Exercices.dir/main.c.o 30c179a7aefe8551 +0 9 1740400419048998063 build.ninja 2e74603cecdb425f diff --git a/cmake-build-debug/Testing/Temporary/LastTest.log b/cmake-build-debug/Testing/Temporary/LastTest.log index 86913aa..5fee919 100644 --- a/cmake-build-debug/Testing/Temporary/LastTest.log +++ b/cmake-build-debug/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Feb 24 13:26 CET +Start testing: Feb 24 13:33 CET ---------------------------------------------------------- -End testing: Feb 24 13:26 CET +End testing: Feb 24 13:33 CET diff --git a/main.c b/main.c index 4b30fd7..8ecfbed 100644 --- a/main.c +++ b/main.c @@ -1,3 +1,5 @@ +#include +#include #include #include @@ -17,8 +19,19 @@ int *alloc_tab(){ return tab; } -void in_tab(int tab[], int cible) { - int occurence=0; +bool dict_sort(int tab[], int cible) { + // Définition et Assignation des variables + int pointer = 1; + int intervale= size; + int pivot; + bool trouve=false; + + while (trouve==false and pointer<=intervale) { + pivot = (pointer+intervale)/2; + if (tab[pivot]> + } + + for (int i=0; i < size; i++) { if (tab[i] == cible) { printf("La cible se trouve dans le tableau\n"); @@ -34,7 +47,7 @@ void in_tab(int tab[], int cible) { } int main(void) { int* tab=alloc_tab(); - in_tab(tab, 5); + dict_sort(tab, 5); free(tab); return 0; } \ No newline at end of file