DEV/DEV1.1/TP06/maximum.c
2022-10-12 16:41:20 +02:00

56 lines
799 B
C

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
srand(time(0));
int tab[10];
int i;
for(i=0;i<10;i++){
tab[i]=(rand()%(50+1-(-50)))-50;
}
int indice;
int max=tab[0];
for(i=1;i<10;i++){
if(max<tab[i]){
max = tab[i];
}
}
for(i=0;i<10;i++){
if(tab[i]==max){
indice=i;
}
}
for(i=0;i<=indice;i++){
if(i==indice){
printf(" |");
}
else{printf(" ");}
}
printf("\n");
for(i=0;i<=indice;i++){
if(i==indice){
printf(" v");
}
else{printf(" ");}
}
printf("\n+");
for(i=0;i<10;i++){
printf("-----+");
}
printf("\n");
for(i=0;i<10;i++){
printf("|%3d, ",tab[i]);
}
printf("|\n+");
for(i=0;i<10;i++){
printf("-----+");
}
printf("\n");
printf("le plus grand elmt est : %d \n", max);
return EXIT_SUCCESS;
}