50 lines
905 B
C
50 lines
905 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
void remplissage( int tab[10]){
|
|
int tour,signe;
|
|
int tab_temp[2];
|
|
srand(time(NULL));
|
|
for (tour=0;tour<10;tour++){
|
|
tab[tour]=rand()%51;
|
|
tab_temp[0]=tab[tour];
|
|
tab_temp[1]=tab[tour]*(-1);
|
|
signe=rand()%2;
|
|
tab[tour]=tab_temp[signe];
|
|
}
|
|
}
|
|
|
|
void inversion(const int tab[10], int tab_inv[10]){
|
|
int tour;
|
|
for (tour=0;tour<10;tour++)
|
|
tab_inv[tour]=tab[(9-tour)];
|
|
}
|
|
|
|
void affichage( int tab[10]){
|
|
int tour;
|
|
printf("+");
|
|
for (tour=0;tour<10;tour++)
|
|
printf("-----+");
|
|
printf("\n");
|
|
printf("|");
|
|
for (tour=0;tour<10;tour++)
|
|
printf("%4d |",tab[tour]);
|
|
printf("\n");
|
|
printf("+");
|
|
for (tour=0;tour<10;tour++)
|
|
printf("-----+");
|
|
printf("\n");
|
|
}
|
|
|
|
int main(void) {
|
|
int tab[10];
|
|
int tab_inv[10];
|
|
remplissage(tab);
|
|
inversion(tab,tab_inv);
|
|
affichage(tab);
|
|
printf("\n");
|
|
printf("\n");
|
|
affichage(tab_inv);
|
|
return EXIT_SUCCESS;
|
|
} |