25 lines
442 B
C
25 lines
442 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <time.h>
|
||
|
#include <math.h>
|
||
|
|
||
|
int main(void) {
|
||
|
int tableau[10];
|
||
|
int i;
|
||
|
int valeur_recherch;
|
||
|
srand(time(NULL));
|
||
|
for(i=0; i<10;i++){
|
||
|
tableau[i]= (rand()%101)-50;
|
||
|
}
|
||
|
printf("Quelle valeur recherchez-vous ?\n");
|
||
|
scanf("%d", &valeur_recherch);
|
||
|
for(i=0; i<10;i++){
|
||
|
if (tableau[i] == valeur_recherch){
|
||
|
printf("%d\n", i);
|
||
|
}
|
||
|
else {
|
||
|
printf("-1\n");
|
||
|
}
|
||
|
}
|
||
|
}
|