2.1.3 : Les sources de la bibliothèque
Écrivons le fichier randinit.cpp :
Nous devons inclure notre header :
1 |
#include "randinit.h"
|
Implémentons la fonction pour initialiser la séquence de nombre pseudo-aléatoire :
1 2 3 4 5 6 7 8 |
///Set the random seed /** @return seed of the random function */ unsigned int initRandom(){ time_t t = time(NULL); srand(t); return t; } |
Le fichier randinit.cpp complet :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
/*************************************** Auteur : Pierre Aubert Mail : pierre.aubert@lapp.in2p3.fr Licence : CeCILL-C ****************************************/ #include "randinit.h" ///Set the random seed /** @return seed of the random function */ unsigned int initRandom(){ time_t t = time(NULL); srand(t); return t; } |
Vous pouvez le télécharger ici.