#include<stdio.h>
#include<stdlib.h>
#include<time.h>

#define SIZE 10

void filltable(int table[]) {
	srand(time(NULL));
	for (int i = 0; i < SIZE; i++) {
		table[i] = rand() % 100;
		srand(rand());
	}
}

void showtable(int table[]) {
	for (int i = 0; i < SIZE; i++) printf("+----");
	printf("+\n");

	for (int i = 0; i < SIZE; i++) printf("| %2d ", table[i]);
	printf("|\n");


	for (int i = 0; i < SIZE; i++) printf("+----");
	printf("+\n");
}

/* Sans la fonction de l'exo 4
void reversetable(int table[SIZE]) {
	int normaltable[SIZE];
	for (int i = 0; i < SIZE; i++) normaltable[i] = table[i];
	for (int i = 0; i < SIZE; i++) table[i] = normaltable[SIZE-1-i];
} */

//Avec la fonction de l'exo 4
void swap(int* x, int* y) {
	int z = *x;
	*x = *y;
	*y = z;
}

void reversetable(int table[SIZE]) {
	for (int i = 0; i < SIZE/2; i++) swap(&table[i], &table[SIZE-i-1]);
}

int main(int argc, char * argv[]) {
	int table[SIZE];

	filltable(table);
	showtable(table);
	reversetable(table);
	showtable(table);
	return EXIT_SUCCESS;
}

