-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstar_pattern_57.c
More file actions
53 lines (53 loc) · 1.17 KB
/
star_pattern_57.c
File metadata and controls
53 lines (53 loc) · 1.17 KB
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
#include <stdio.h>
int main()
{
int n;
printf("Enter the Row: ");
scanf("%d", &n);
int k = 1, f = 0;
for (int i = 0; i < n+1; i++)
{
k = 1;
f = 0;
for (int j = 0; j < i * 2 + 1; j++)
{
if (i * 2 + 1 == j + 1 || j == 0)
{
printf("*");
}
else if (j < i)
{
printf("%d", k);
k++;
}
else
{
printf("%d", k);
k--;
}
}
printf("\n");
}
for (int i = 0; i < n; i++)
{
k = 1;
for (int j = 0; j < n-i-1; j++)
{
if ( j == 0)
{
printf("*");
}
printf("%d",k);
k++;
}
for (int j = n-i-2; j > 0; j--)
{
printf("%d",j);
if(j-1==0){
printf("*");
}
}
printf("\n");
}
return 0;
}