From 2a2fa78d3b147a0c3a287d25996b14e48d037c36 Mon Sep 17 00:00:00 2001 From: Kshitiz Raj Date: Thu, 14 Oct 2021 12:11:17 +0530 Subject: [PATCH] Add Zig Zag Pattern Program --- ZigZagPattern.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 ZigZagPattern.cpp diff --git a/ZigZagPattern.cpp b/ZigZagPattern.cpp new file mode 100644 index 0000000..e345f7f --- /dev/null +++ b/ZigZagPattern.cpp @@ -0,0 +1,67 @@ +#include +using namespace std; + +int main() +{ + + int n; + cin >> n; + + for (int i = 1; i <= 3; i++) + { + if (i == 1) + { + int c = 0; + for (int j = 1; j <= n; j++) + { + if (j == 1 || j == 2) + { + cout << " "; + } + else + { + if (c % 4 == 0) + { + cout << "* "; + } + else + { + cout << " "; + } + c++; + } + } + } + else if (i == 2) + { + for (int j = 1; j <= n; j++) + { + if (j % 2 == 0) + { + cout << "* "; + } + else + { + cout << " "; + } + } + } + else + { + for (int j = 1; j <= n; j++) + { + if (j % 4 == 1) + { + cout << "* "; + } + else + { + cout << " "; + } + } + } + cout << endl; + } + + return 0; +} \ No newline at end of file