From 3f1d429d5f217301a97a66a7c3115b3ad346ee25 Mon Sep 17 00:00:00 2001 From: belliash Date: Sat, 20 Apr 2019 13:49:45 +0200 Subject: [PATCH] =?UTF-8?q?The=20program=20code=20for=20printing=20Pascal?= =?UTF-8?q?=E2=80=99s=20Triangle.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/pascal_triangle.aer | 25 +++++++++++++++++++++++++ tests/pascal_triangle.exp | 5 +++++ 2 files changed, 30 insertions(+) create mode 100644 tests/pascal_triangle.aer create mode 100644 tests/pascal_triangle.exp diff --git a/tests/pascal_triangle.aer b/tests/pascal_triangle.aer new file mode 100644 index 0000000..bb635bd --- /dev/null +++ b/tests/pascal_triangle.aer @@ -0,0 +1,25 @@ +class Program { + + private int fun(int $y) { + int $result = 1; + for(int $z = 1; $z <= $y; $z++) { + $result *= $z; + } + return $result; + } + + void main() { + int $z; + int $y = 5; + for(int $x = 0; $x < $y; $x++) { + for($z = 0; $z <= ($y - $x - 2); $z++) { + print(' '); + } + for($z = 0; $z <= $x; $z++) { + print($this->fun($x) / ($this->fun($z) * $this->fun($x - $z)), ' '); + } + print("\n"); + } + } + +} diff --git a/tests/pascal_triangle.exp b/tests/pascal_triangle.exp new file mode 100644 index 0000000..58032ed --- /dev/null +++ b/tests/pascal_triangle.exp @@ -0,0 +1,5 @@ + 1 + 1 1 + 1 2 1 + 1 3 3 1 +1 4 6 4 1