-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathPattern.c
82 lines (81 loc) · 1.87 KB
/
Pattern.c
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
#include<stdio.h>
int main() {
char prnt = '*';
int i, j, k, s, p, r, nos = 7;
for (i = 1; i <= 5; i++)
{
for (j = 1; j <= i; j++)
{
if ((i % 2) != 0 && (j % 2) != 0)
{
printf("%3c", prnt);
}
else if ((i % 2) == 0 && (j % 2) == 0)
{
printf("%3c", prnt);
}
else
{
printf(" ");
}
}
for (s = nos; s >= 1; s--)
{ // for the spacing factor
printf(" ");
}
for (k = 1; k <= i; k++)
{ //Joining seperate figures
if (i == 5 && k == 1)
{
continue;
}
else if ((k % 2) != 0)
{
printf("%3c", prnt);
}
else
{
printf(" ");
}
}
printf("\n");
nos = nos - 2; // space control
}
nos = 1; // remaining half..
for (p = 4; p >= 1; p--)
{
for (r = 1; r <= p; r++)
{
if ((p % 2) != 0 && (r % 2) != 0)
{
printf("%3c", prnt);
}
else if ((p % 2) == 0 && (r % 2) == 0)
{
printf("%3c", prnt);
}
else
{
printf(" ");
}
}
for (s = nos; s >= 1; s--)
{
printf(" ");
}
for (k = 1; k <= p; k++)
{
if ((k % 2) != 0)
{
printf("%3c", prnt);
}
else
{
printf(" ");
}
}
nos = nos + 2; // space control
printf("\n");
}
return 0;
}