DEV/DEV1.1/TP06:Tableaux/recherche.c
2022-10-12 16:41:36 +02:00

27 lines
608 B
C

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
int i;
int n;
int m;
int min=-1;
int tab[10];
srand(time(NULL));
for (i=0;i<10;i++){
tab[i]=((rand()%101)-50);
} printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
for (i=0;i<10;i++){
printf("| %3d ",tab[i]);
} printf("|\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
printf("Veuillez saisir un entier : ");
scanf("%d",&m);
for (i=0;i<10;i++){
if (tab[i]==m){
min = i;
break;
}
} printf("Le plus petit indice ou se trouve votre entier est %d .\n",min);
return 0;
}