summaryrefslogtreecommitdiff
path: root/sem_4/Algo/TP3/TriOutilsSimples.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sem_4/Algo/TP3/TriOutilsSimples.cpp')
-rw-r--r--sem_4/Algo/TP3/TriOutilsSimples.cpp27
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;
+}