-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2023.c
62 lines (50 loc) · 1.15 KB
/
2023.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
#include<stdio.h>
#include<stdlib.h>
int OutputLeadingSpaces(int nSpaces){
int i;
for (i = 0; i <= nSpaces; i++)
{
printf(" ");
}
}
int OutputLineOfStars(int nStars)
{
int i;
for (i = 1; i <= nStars; i++)
{
printf("*");
}
printf("\n");
}
void Adjust(int NoOfSpaces, int NoOfStars)
{
OutputLeadingSpaces(NoOfSpaces);
OutputLineOfStars(NoOfStars);
}
void Initialise(int MaxNoOfStars, int NoOfSpaces, int NoOfStars)
{
int i, j;
//replace maxNoOfStars/2 to MaxNoOfStars and uncomment the other lines bellow
for (i = 0; i < MaxNoOfStars/2; i++)
{
Adjust(NoOfSpaces, NoOfStars);
if (i < MaxNoOfStars/2)
{
NoOfSpaces--;
NoOfStars += 2;
}
else
{
///NoOfSpaces++;
//NoOfStars -= 2;
}
}
}
int main()
{
int MaxNoOfStars = 9;
int NoOfSpaces = MaxNoOfStars / 2;
int NoOfStars = 1;
Initialise(MaxNoOfStars, NoOfSpaces, NoOfStars);
return(0);
}