67 lines
1.3 KiB
C
67 lines
1.3 KiB
C
# include <stdio.h>
|
|
# include <stdlib.h>
|
|
# include <time.h>
|
|
# define TAILLE_TABLEAU 10
|
|
|
|
int main(void){
|
|
int tab[TAILLE_TABLEAU];
|
|
int tab_inverse[TAILLE_TABLEAU];
|
|
int i;
|
|
srand(time(NULL));
|
|
|
|
/* Remplissage du tableau */
|
|
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
|
tab[i] = (rand() % 100) - 50;
|
|
}
|
|
/* Affichage du tableau */
|
|
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
|
printf("+-----");
|
|
}
|
|
printf("+\n");
|
|
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
|
if (tab[i] < 10 && tab[i] >= 0) {
|
|
printf("| %d ", tab[i]);
|
|
}
|
|
else if (tab[i] < -9) {
|
|
printf("| %d ", tab[i]);
|
|
}
|
|
else {
|
|
printf("| %d ", tab[i]);
|
|
}
|
|
}
|
|
printf("|\n");
|
|
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
|
printf("+-----");
|
|
}
|
|
printf("+\n");
|
|
|
|
/* Remplissage du tableau inverse */
|
|
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
|
tab_inverse[i] = tab[TAILLE_TABLEAU-i-1];
|
|
}
|
|
|
|
/* Affichage du tableau */
|
|
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
|
printf("+-----");
|
|
}
|
|
printf("+\n");
|
|
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
|
if (tab_inverse[i] < 10 && tab_inverse[i] >= 0) {
|
|
printf("| %d ", tab_inverse[i]);
|
|
}
|
|
else if (tab_inverse[i] < -9) {
|
|
printf("| %d ", tab_inverse[i]);
|
|
}
|
|
else {
|
|
printf("| %d ", tab_inverse[i]);
|
|
}
|
|
}
|
|
printf("|\n");
|
|
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
|
printf("+-----");
|
|
}
|
|
printf("+\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|