diff options
| author | Gaspard Coulet <gaspard.coulet@mines-ales.org> | 2021-04-28 23:05:53 +0200 |
|---|---|---|
| committer | Gaspard Coulet <gaspard.coulet@mines-ales.org> | 2021-04-28 23:05:53 +0200 |
| commit | 9fe033ea88c2f705ec18c232873d056e0c229d72 (patch) | |
| tree | 0647dc8c51610c7336c88c04de2068ea14b21e17 /sem_4/Algo/TP3/TriOutilsSimples.cpp | |
Initial commit
Diffstat (limited to 'sem_4/Algo/TP3/TriOutilsSimples.cpp')
| -rw-r--r-- | sem_4/Algo/TP3/TriOutilsSimples.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sem_4/Algo/TP3/TriOutilsSimples.cpp b/sem_4/Algo/TP3/TriOutilsSimples.cpp new file mode 100644 index 0000000..e915ac4 --- /dev/null +++ b/sem_4/Algo/TP3/TriOutilsSimples.cpp @@ -0,0 +1,27 @@ +#include <iostream> + + +/************************ +Generaux +****************************/ +int max(int a, int b) {if (a > b) return a; return b;} + +int moitieSuperieure(int n){ + if (n % 2 == 0) return n / 2; return (n+1) / 2;} + +void imprimer(int n, int T[]){ + for (int i=0; i<n; i++) std::cout<<T[i]<<" ";} + +void genererInverse(int n, int T[]){ + for (int i=0; i<n; i++) T[i]=n-i; +} + + +void genererRandom(int n, int Max, int T[]){//rempli le tableau T de n nombres aléatoires, tous enttre 0 et Max + for (int i=0; i<n; i++) T[i]=rand() % (Max + 1); +} + + +void echanger(int T[], int i, int j){ + int temp=T[i]; T[i]=T[j]; T[j]=temp; +} |
