Website Summary Files Commits Branches @commit @diff @stats
path: root / Week08 / Exercise10.cpp
diff options
context:
space:
mode:
1 files changed, 23 insertions, 0 deletions
-rw-r--r--Week08/Exercise10.cpp23
diff --git a/Week08/Exercise10.cpp b/Week08/Exercise10.cpp
new file mode 100644
index 0000000..024d4c8
--- /dev/null
+++ b/Week08/Exercise10.cpp
@@ -0,0 +1,23 @@
+#include <iostream>
+
+int main() {
+ const unsigned int SIZE = 11;
+ unsigned int pascal[SIZE][SIZE] = { 0 };
+
+ for (unsigned int i = 0; i < SIZE; i++)
+ pascal[i][0] = pascal[i][i] = 1;
+
+ for (unsigned int row = 2; row < SIZE; row++)
+ for (unsigned int col = 1; col < row; col++)
+ /* Елемента над и в ляво на текущия, сумирано с елемента над текущия.
+ */
+ pascal[row][col] = pascal[row - 1][col - 1] + pascal[row - 1][col];
+
+ for (unsigned int row = 0; row < SIZE; row++) {
+ for (unsigned int col = 0; col < SIZE; col++)
+ std::cout << pascal[row][col] << ' ';
+ std::cout << std::endl;
+ }
+
+ return 0;
+}