diff options
| author | Anhgelus Morhtuuzh <anhgelus@anhgelus.world> | 2025-03-10 10:31:33 +0100 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <anhgelus@anhgelus.world> | 2025-03-10 10:31:33 +0100 |
| commit | 4a3afaf44aa29e66a6c879c60322015a2920a5ab (patch) | |
| tree | 64d3e7748078b4215341aeead3b30eaaf28070ad /semestre 2/informatique/tme/semaine5/31_image_mystere.c | |
| parent | 77bfb2ccd3152c1f41d43dc192ba86ca8fd0f72f (diff) | |
Ajout de la semaine des cours du 3 au 7 mars
Diffstat (limited to 'semestre 2/informatique/tme/semaine5/31_image_mystere.c')
| -rw-r--r-- | semestre 2/informatique/tme/semaine5/31_image_mystere.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/semestre 2/informatique/tme/semaine5/31_image_mystere.c b/semestre 2/informatique/tme/semaine5/31_image_mystere.c new file mode 100644 index 0000000..51ca321 --- /dev/null +++ b/semestre 2/informatique/tme/semaine5/31_image_mystere.c @@ -0,0 +1,29 @@ +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +void calcule_borne_sup(int *tab, int taille){ + int dec = -1; + for (int i = 0; i < taille; i++) { + tab[i] += dec; + dec = tab[i]; + } +} + +int tire_non_equi(int *tab, int taille){ + int tire = rand()%100; + int i; + for (i = taille -1; tab[i] > tire; i--); + printf("%d - %d <= %d\n", i, tab[i], tire); + return i; +} + +int main() { + srand(time(NULL)); + int tab[] = {17, 28, 50, 5}; + calcule_borne_sup(tab, 4); + for (int i = 0; i < 4; i++) printf("%d, ", tab[i]); + printf("\n"); + printf("%d", tire_non_equi(tab, 4)); + return 0; +} |
