blob: 93414400460556270415fdd79ae857eb5d39a817 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "question1.h"
/* j'ai fait le choix d'allouer un tableau et de le renvoyer, car ca me semble plus naturel de proceder comme ça */
int *alloue_tableau(int n){
return (int *)malloc(sizeof(int)*n);
}
int *desalloue_tableau(int *t, int n){
free(t);
}
void remplir_tableau(int *t, int n, int V){
srand(time(NULL));
for (int i = 0; i < n; i++){
t[i] = rand()%V;
}
}
void afficher_tableau(int *t, int n){
printf("[");
for (int i = 0; i < n; i++){
printf("%d ", t[i]);
}
printf("]\n");
}
|