49 lines
940 B
C
49 lines
940 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <time.h>
|
||
|
|
||
|
void echange(int* a , int* b){
|
||
|
int c;
|
||
|
c=*a;
|
||
|
*a=*b;
|
||
|
*b=c;
|
||
|
}
|
||
|
|
||
|
int afficheTab (int tab[]){
|
||
|
int i;
|
||
|
printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||
|
for (i=0;i<10;i++){
|
||
|
printf("| %3d ",tab[i]);
|
||
|
} printf("|\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||
|
}
|
||
|
|
||
|
int remplissageAleatoire (int tab[]){
|
||
|
int i;
|
||
|
srand(time(NULL));
|
||
|
for (i=0;i<10;i++){
|
||
|
tab[i]=((rand()%101)-50);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int inverseTab (int tab[]){
|
||
|
int i;
|
||
|
int j;
|
||
|
int k;
|
||
|
printf("Voici le tableaux inverse:\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||
|
i=9;
|
||
|
for(j=0;j<5;j++){
|
||
|
echange(&tab[i],&tab[j]);
|
||
|
i--;
|
||
|
}
|
||
|
for (i=0;i<10;i++){
|
||
|
printf("| %3d ",tab[i]);
|
||
|
} printf("|\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||
|
}
|
||
|
|
||
|
int main() {
|
||
|
int tab[10];
|
||
|
remplissageAleatoire(tab);
|
||
|
afficheTab(tab);
|
||
|
inverseTab(tab);
|
||
|
return 0;
|
||
|
}
|