99 lines
1.7 KiB
C
99 lines
1.7 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
int main(void) {
|
|
int tab[10];
|
|
int tabreverse[10];
|
|
int n;
|
|
int i;
|
|
int j;
|
|
int k;
|
|
int d;
|
|
int res = 0;
|
|
int max = -51;
|
|
int min = 50;
|
|
int result;
|
|
int cas;
|
|
srand(time(NULL));
|
|
for (i=0 ; i<10 ; i++){
|
|
n = ((rand()%101)-50);
|
|
tab[i] = n;
|
|
}
|
|
//Miroir
|
|
for(i=0 ; i<10 ; i++){
|
|
tabreverse[i] = tab[9-i];
|
|
}
|
|
//Maximum
|
|
for (k = 0 ; k<10 ; k++){
|
|
if(tab[k]>max){
|
|
max = tab[k];
|
|
}
|
|
}
|
|
for (i=0 ; i<10 ; i++){
|
|
if(tab[i] != max){
|
|
printf(" ");
|
|
}
|
|
else if(tab[i] == max){
|
|
printf(" | ");
|
|
}
|
|
}
|
|
printf("\n");
|
|
for(i=0;i<10;i++){
|
|
if(tab[i] != max){
|
|
printf(" ");
|
|
}
|
|
else if(tab[i] == max){
|
|
printf(" V ");
|
|
}
|
|
}
|
|
printf("\n");
|
|
//Remplissage
|
|
printf("Tableau de base.\n");
|
|
printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
|
for(j=0 ; j<10 ; j++){
|
|
printf("| %3d ", tab[j]);
|
|
}
|
|
printf("|\n");
|
|
printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
|
//Mirroir
|
|
printf("Tableau Miroir.\n");
|
|
printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
|
for(j=0 ; j<10 ; j++){
|
|
printf("| %3d ", tabreverse[j]);
|
|
}
|
|
printf("|\n");
|
|
printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
|
//Recherche
|
|
printf("Recherche de nombre.\n");
|
|
printf("Entrer une valeur : ");
|
|
scanf("%d", &n);
|
|
for(i = 0 ; i < 10 ; i++){
|
|
if(tab[i] == n){
|
|
result = tab[i];
|
|
cas = i;
|
|
break;
|
|
}else{
|
|
result = -52;
|
|
}
|
|
}
|
|
if(result != -52){
|
|
printf("La valeur %d se trouve dans la case : %d\n", result, cas);
|
|
}else{
|
|
result = -1;
|
|
printf("%d\n", result);
|
|
}
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|