-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSource.cpp
97 lines (72 loc) · 1.31 KB
/
Source.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//C++ Language
#include <iostream>
using namespace std;
int main()
{
int oddNumber = 11;
bool check = false;
if (oddNumber % 2 == 1)
check = true;
if (check)
{
//printing the first line
for (int i = 1; i <= oddNumber; i++)
{
cout << "*\t";
}
cout << "\n";
int space1 = 1;
int oddNumberU = oddNumber - 1;
int middleSpace;
int space2;
do
{
for (int i = 1; i <= space1; i++)
{
cout << "\t";
}
cout << "*";
middleSpace = oddNumberU - 2;
if (middleSpace != 0)
{
for (int i = 1; i <= middleSpace; i++)
{
cout<<"\t";
}
cout << "*";
}
cout << "\n";
space1++;
oddNumberU = middleSpace;
space2 = space1; //6
} while (middleSpace != 0);
space2 = space2 - 2; //4
middleSpace = 2;
int lineNo = oddNumber/2;
do
{
for (int i = 1; i <= space2; i++)
{
cout << "\t";
}
if (space2 != 0)
cout << "*";
if (middleSpace <= (oddNumber - 3))
{
for (int i = 1; i <= middleSpace; i++)
{
cout << "\t";
}
cout << "*";
cout << "\n";
}
middleSpace = middleSpace + 2;
space2--;
--lineNo;
} while (lineNo != 0);
for (int i = 1; i <= oddNumber; i++)
{
cout << "*\t";
}
}
}