summaryrefslogtreecommitdiff
path: root/sem_2/HLIN202/TP/TP3-4/bonus
diff options
context:
space:
mode:
Diffstat (limited to 'sem_2/HLIN202/TP/TP3-4/bonus')
-rw-r--r--sem_2/HLIN202/TP/TP3-4/bonus/bonus.cpp33
-rw-r--r--sem_2/HLIN202/TP/TP3-4/bonus/progbin0 -> 9263 bytes
2 files changed, 33 insertions, 0 deletions
diff --git a/sem_2/HLIN202/TP/TP3-4/bonus/bonus.cpp b/sem_2/HLIN202/TP/TP3-4/bonus/bonus.cpp
new file mode 100644
index 0000000..8a8b6a3
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP3-4/bonus/bonus.cpp
@@ -0,0 +1,33 @@
+#include<iostream>
+#include<math.h>
+
+void triangle (int k);
+int combo ( int, int);
+
+int main () {
+ triangle ( 20 );
+ return 0;
+
+}
+
+void triangle ( int k ) {
+ int n,p,ligne;
+ n = 0;
+ p = 0;
+ ligne = 1;
+ while ( p <= k) {
+ while ( n <=p ) {
+ for ( int i=0; i < ligne; i ++) {
+ std::cout<< combo ( n, i ) << " ";
+ }
+ std::cout<<std::endl;
+ n ++;
+ ligne ++;
+ }
+ p ++;
+}
+}
+
+int combo ( int n, int p) {
+ return (n == p || p == 0) ? 1 : combo(n-1,p) + combo ( n-1,p-1);
+}
diff --git a/sem_2/HLIN202/TP/TP3-4/bonus/prog b/sem_2/HLIN202/TP/TP3-4/bonus/prog
new file mode 100644
index 0000000..da45351
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP3-4/bonus/prog
Binary files differ