We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents cafbdb4 + f51f967 commit ca30c9eCopy full SHA for ca30c9e
1 file changed
c++/Dimond_pattern.cpp
@@ -0,0 +1,35 @@
1
+#include <iostream>
2
+using namespace std;
3
+
4
+int main() {
5
+ int n;
6
+ cout << "Enter the number of rows (should be an odd number): ";
7
+ cin >> n;
8
9
+ if (n % 2 == 0) {
10
+ cout << "Please enter an odd number for a symmetric diamond pattern."<<endl;
11
+ return 1;
12
+ }
13
14
+ for (int i = 1; i <= n; i += 2) {
15
+ for (int j = 0; j < (n - i) / 2; j++) {
16
+ cout << " ";
17
18
+ for (int j = 0; j < i; j++) {
19
+ cout << "*";
20
21
+ cout <<endl;
22
23
24
+ for (int i = n - 2; i >= 1; i -= 2) {
25
26
27
28
29
30
31
32
33
34
+ return 0;
35
+}
0 commit comments