APL/APL1.1/TP11/miroir.c

41 lines
764 B
C
Raw Permalink Normal View History

2021-10-05 16:17:21 +02:00
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void showtable(int tablesize, int* table) {
for (int i = 0; i < tablesize; i++) printf("+-----");
printf("+\n");
for (int i = 0; i < tablesize; i++) printf("| %3d ", table[i]);
printf("|\n");
for (int i = 0; i < tablesize; i++) printf("+-----");
printf("+\n");
}
int main(int argc, char * argv[]) {
int tab[10] = {};
srand(time(NULL));
int rand_v = rand();
for (int i = 0; i < 10; i++) {
srand(rand_v);
tab[i] = rand() % 101 > 50 ? (-rand() % 100) + 50: (rand() % 100) - 50;
rand_v = rand();
}
showtable(10, tab);
int reserversetab[10] = {};
for (int i = 0; i < 10; i++) {
reserversetab[i] = tab[9-i];
}
printf("\n\n");
showtable(10, reserversetab);
return EXIT_SUCCESS;
}