From 4894690dab997dbc6bb076b52f503367362c96c8 Mon Sep 17 00:00:00 2001 From: AnandiBhardwaj <109234205+AnandiBhardwaj@users.noreply.github.com> Date: Mon, 31 Oct 2022 11:04:46 +0530 Subject: [PATCH] Create Y-shaped-pattern --- C++/Y-shaped-pattern | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 C++/Y-shaped-pattern diff --git a/C++/Y-shaped-pattern b/C++/Y-shaped-pattern new file mode 100644 index 0000000..62e3b15 --- /dev/null +++ b/C++/Y-shaped-pattern @@ -0,0 +1,37 @@ +#include +using namespace std; + +int main() +{ + + int N = 12; + + int s = N / 2; + int t = s; + + + for (int i = 0; i < N; i++) { + + if (i > s) { + + for (int j = 0; j < s; j++) + cout << " "; + } + else { + + for (int j = 0; j < i; j++) + cout << " "; + + cout << "*"; + + for (int k = 0; k < 2 * t; k++) + cout << " "; + + t--; + } + + cout << " *" << endl; + } + + return 0; +}