DEV/BUT1/DEV1.1/Tableaux/remplissage.c

68 lines
807 B
C
Raw Normal View History

2024-02-01 13:55:03 +01:00
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#define MAX 50
#define MIN -50
int generate_random(int min, int max)
{
return min + rand() / (RAND_MAX / (max - min + 1) + 1);
}
int main(void)
{
int tab[10];
srand(time(NULL));
for (int i = 0; i < 10; i++)
{
tab[i] = generate_random(MIN, MAX);
}
for (int i = 0; i < 10; i++)
{
if (i == 9)
{
printf("+-----+\n");
}
else
{
printf("+-----");
}
}
for (int i = 0; i < 10; i++)
{
if (i == 9)
{
printf("|%4d |\n", tab[i]);
}
else
{
printf("|%4d ", tab[i]);
}
}
for (int i = 0; i < 10; i++)
{
if (i == 9)
{
printf("+-----+\n");
}
else
{
printf("+-----");
}
}
exit(EXIT_SUCCESS);
}