debut TP16
This commit is contained in:
@@ -4,19 +4,23 @@
|
||||
|
||||
int remplissage( int tab[10]){
|
||||
int tour,signe;
|
||||
int tab_temp[2];
|
||||
srand(time(NULL));
|
||||
for (tour=0;tour<10;tour++){
|
||||
tab[tour]=rand()%51;
|
||||
int tab_temp[2]={tab[tour],tab[tour]*(-1)};
|
||||
tab_temp[0]=tab[tour];
|
||||
tab_temp[1]=tab[tour]*(-1);
|
||||
signe=rand()%2;
|
||||
tab[tour]=tab_temp[signe];
|
||||
}
|
||||
return *tab;
|
||||
}
|
||||
|
||||
int inversion(const int tab[10], int tab_inv[10]){
|
||||
int tour;
|
||||
for (tour=0;tour<10;tour++)
|
||||
tab_val[tour]=tab[(9-tour)];
|
||||
tab_inv[tour]=tab[(9-tour)];
|
||||
return *tab_inv;
|
||||
}
|
||||
|
||||
void affichage( int tab[10]){
|
||||
@@ -33,11 +37,12 @@ void affichage( int tab[10]){
|
||||
for (tour=0;tour<10;tour++)
|
||||
printf("-----+");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int tab[10];
|
||||
remplissage(tab);
|
||||
int tab_inv[10];
|
||||
remplissage(tab);
|
||||
inversion(tab,tab_inv);
|
||||
affichage(tab);
|
||||
printf("\n");
|
||||
|
||||
Reference in New Issue
Block a user