aboutsummaryrefslogtreecommitdiff
path: root/semestre 2/informatique/tme/semaine5/31_image_mystere.c
blob: 29264e14c5d88b8a671a2b0b9d68c78bc1836e7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#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 = taille -1;
	/*while (i >= 0) {
		if (tire > tab[i]) break;
		i--;
	}
	i++;*/
	for (i = taille -1; tab[i] >= tire; i--);
	i++;
	printf("%d >= %d\n", 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;
}