forked from shivaylamba/Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpentagon pattern.c
95 lines (82 loc) · 1.53 KB
/
pentagon 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
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
int main()
{
int n,i,j,k,s,m,b,x=0,y,h;
printf("EnTer tHe nUmBer YoU WaNt tO dIsplaY PattErn")
scanf("%d", &n);
k=1;
// Complete the code to print the pattern.
for(i=n;i>0;i--)
{
s=n;
b=n;
for(j=0;j<i;j++)
{
printf("%d ",i);
}
for(j=2;j<i;j++)
{
if(i==1)
{
printf("2");
}
else
printf("%d ",i);
}
b=b-x;
for(m=0;m<k;m++)
{
if(b==1)
{
b=b+1;
}
else
{
printf("%d ",b);
b++;
}
}
printf("\n");
for(m=0;m<k&&k<n;m++)
{
printf("%d ",s);
s--;
}
k++;
x++;
}
//END OF FIRST HALF
y=n;
for(i=1;i<n;i++)
{
h=n;
b=n;
for(j=y-2;j>0;j--)
{
printf("%d ",h);
h--;
}
for(j=0;j<=i;j++)
{
printf("%d ",i+1);
}
y--;
for(m=0;m<i;m++)
{
printf("%d ",i+1);
}
b=i+2;
for(m=1;m<n-1&&b<=n;m++)
{
printf("%d ",b);
b++;
}
printf("\n");
}
getch();
return 0;
}