diff --git a/2024/aleatoire/.gitignore b/2024/aleatoire/.gitignore new file mode 100644 index 0000000..aa3808c --- /dev/null +++ b/2024/aleatoire/.gitignore @@ -0,0 +1,82 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* +*.qbs.user* +CMakeLists.txt.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + +# Directories with generated files +.moc/ +.obj/ +.pch/ +.rcc/ +.uic/ +/build*/ diff --git a/2024/aleatoire/aleatoire.pro b/2024/aleatoire/aleatoire.pro new file mode 100644 index 0000000..36e897b --- /dev/null +++ b/2024/aleatoire/aleatoire.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +CONFIG += console c++17 +CONFIG -= app_bundle +CONFIG -= qt + +SOURCES += \ + dice.cpp \ + main.cpp + +HEADERS += \ + dice.h diff --git a/2024/aleatoire/dice.cpp b/2024/aleatoire/dice.cpp new file mode 100644 index 0000000..ebfa5d9 --- /dev/null +++ b/2024/aleatoire/dice.cpp @@ -0,0 +1,12 @@ +#include "dice.h" + +#include + +unsigned int dice(unsigned int minDice, unsigned int maxDice) +{ + static std::random_device rd; + static std::mt19937 gen(rd()); + static std::uniform_int_distribution<> distrib(minDice, maxDice); + + return distrib(gen); +} diff --git a/2024/aleatoire/dice.h b/2024/aleatoire/dice.h new file mode 100644 index 0000000..92c19b4 --- /dev/null +++ b/2024/aleatoire/dice.h @@ -0,0 +1,7 @@ +#ifndef _dice_hpp_ +#define _dice_hpp_ + +/** Petit jeu avec des static dedans **/ +unsigned int dice(unsigned int minDice, unsigned int maxDice); + +#endif diff --git a/2024/aleatoire/main.cpp b/2024/aleatoire/main.cpp new file mode 100644 index 0000000..3129fb9 --- /dev/null +++ b/2024/aleatoire/main.cpp @@ -0,0 +1,9 @@ +#include + +using namespace std; + +int main() +{ + cout << "Hello World!" << endl; + return 0; +}