From 87410466274e64c51caaf99a55cd7be6db66e2ba Mon Sep 17 00:00:00 2001
From: Abivarman <abivarman.kandiah@etu.hesge.ch>
Date: Thu, 11 Nov 2021 18:49:45 +0100
Subject: [PATCH] Ex 8

---
 header/tab_uni_malloc.h | 11 +++++++++++
 src/main.c              |  7 +++++++
 src/tab_uni_malloc.c    | 17 +++++++++++++++++
 3 files changed, 35 insertions(+)

diff --git a/header/tab_uni_malloc.h b/header/tab_uni_malloc.h
index 0814bfd..3141c93 100644
--- a/header/tab_uni_malloc.h
+++ b/header/tab_uni_malloc.h
@@ -80,4 +80,15 @@ int64_t FindLowIndex(int64_t *tab, int64_t tab_len);
 */ 
 void TriInsertionDescent(int64_t *tab, int64_t tab_len);
 
+/**
+   @brief  Find how many smaller value than val in table
+   @param  [int] *tab, input table
+   @param  [int] tab_len, table lenght
+   @param  [int] val
+   @return [int64_t] How many value
+*/ 
+int64_t FindHowManySmaller(int64_t *tab, int64_t tab_len, int64_t val);
+
+
+
 #endif
\ No newline at end of file
diff --git a/src/main.c b/src/main.c
index 29d458d..6e6529b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -47,7 +47,14 @@ int main()
     PrintTableau(tab, size);
 
     //8.
+    int64_t input_value = 0;
+    printf("\nEntrez une valeur : \n");
+    scanf(" %ld", &input_value);
+    printf("Il y a %ld d'élements plus petit que %ld dans le tableau. \n", FindHowManySmaller(tab,size, input_value),input_value);
+
+    //9. 
     
+
     //Free the Malloc
     free(tab);
     return 0;
diff --git a/src/tab_uni_malloc.c b/src/tab_uni_malloc.c
index 6527243..8607f46 100644
--- a/src/tab_uni_malloc.c
+++ b/src/tab_uni_malloc.c
@@ -147,3 +147,20 @@ void TriInsertionDescent(int64_t *tab, int64_t tab_len)
         tab[pos] = tmp;
     }
 }
+
+/**
+   @brief  Find how many smaller value than val in table
+   @param  [int] *tab, input table
+   @param  [int] tab_len, table lenght
+   @param  [int] val
+   @return [int64_t] How many value
+*/ 
+int64_t FindHowManySmaller(int64_t *tab, int64_t tab_len, int64_t val) 
+{  
+    int64_t compteur = 0;
+    for (int64_t i = 0; i < tab_len; i++)
+    {
+        if(tab[i] < val){compteur++;}
+    }
+    return compteur;
+}
-- 
GitLab