-
Notifications
You must be signed in to change notification settings - Fork 1
/
butter_fly_2.c
51 lines (50 loc) · 1.07 KB
/
butter_fly_2.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
/*
https://www.hackerrank.com/contests/hostel-challenge-2-0/challenges/butter-fly-2
https://www.hackerrank.com/contests/hostel-challenge-2-0/challenges/butter-fly-2/submissions/code/1301489270
*/
#include<stdio.h>
int main()
{
int i,j,k,n;
scanf("%d",&n);
if(n>1 && n<20)
{
for(i=0;i<n-1;i++)
{
for(j=0;j<=i;j++)
{
printf("* ");
}
for(k=0;k<2*(2*n-2*i-3);k++)
{
printf(" ");
}
for(j=0;j<=i;j++)
{
printf("* ");
}
printf("\n");
}
for(i=0;i<2*n-1;i++)
{
printf("* ");
}
for(i=0;i<n-1;i++)
{
printf("\n");
for(j=0;j<n-i-1;j++)
{
printf("* ");
}
for(k=0;k<2*(2*i+1);k++)
{
printf(" ");
}
for(j=0;j<n-i-1;j++)
{
printf("* ");
}
}
}
return 0;
}