32 lines
945 B
C
32 lines
945 B
C
#include "compare.h"
|
|
|
|
// Affiche T[i] avec le bon format suivant le type t
|
|
void print(type_t t, void *T, int i) {
|
|
// Pour l'affichage des types:
|
|
// - entier, format %2i
|
|
// - caractère, format %c
|
|
// - double, format %+1.2lf
|
|
// - chaîne, format %s
|
|
// - point, format (%.1lf,%.1lf)
|
|
}
|
|
|
|
// Initialisation aléatoire de l'élément T[i]
|
|
void init(type_t t, void *T, int i) {
|
|
// Pour INT: entiers aléatoires dans [0,100[
|
|
// Pour CHAR: lettres majuscules aléatoires
|
|
// Pour DOUBLE: double aléatoires dans [-1,+1] avec 2 chiffres
|
|
// Pour STRING: construit une chaîne aléatoire d'au plus MAXSTR char
|
|
// Pour POINT: point aléatoire de [0,10[ x [0,10[ avec 1 chiffre
|
|
}
|
|
|
|
// Affiche n fois le même la chaîne s.
|
|
void rule(int n, string s) {
|
|
for (int i = 0; i < n; i++)
|
|
printf("%s", s);
|
|
}
|
|
|
|
// Affiche le contenu du tableau array d'éléments de type t
|
|
void print_array(void *array, type_t t, int nb) {
|
|
printf("\n\n");
|
|
}
|