12 Octobre
This commit is contained in:
27
DEV1.1/TP06:Tableaux/recherche.c
Normal file
27
DEV1.1/TP06:Tableaux/recherche.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user