Skip to content
Snippets Groups Projects
Commit 87410466 authored by abivarma.kandiah's avatar abivarma.kandiah
Browse files

Ex 8

parent 36e1d4bd
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -47,6 +47,13 @@ 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);
......
......@@ -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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment