aboutsummaryrefslogtreecommitdiff
path: root/semestre 2/informatique/tme/semaine5/31_image_mystere.c
blob: 51ca3210658184e85da30a6ff6872cf5877b055e (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
#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;
}