-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pattern00009.c
55 lines (51 loc) · 1.04 KB
/
Pattern00009.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
/*
ABCDEFGFEDCBA
ABCDEF FEDCBA
ABCDE EDCBA
ABCD DCBA
ABC CBA
AB BA
A A
*/
#include <stdio.h>
int main()
{
// My
// Approach
int i, j, k=0, temp, blank = 0;
int lines = 6, diff[7] = { 0, 1, 3, 5, 7, 9, 11 };
char symbol = 'A';
for (i = lines; i >= 0; i--)
{
printf("\n");
symbol = 'A';
for (j = i; j >= 0; j--)
printf("%c", symbol++);
blank = diff[k++];
for (j = 0; j < blank; j++)
printf(" ");
symbol = 'F' - (blank / 2);
if (blank == 0)
temp = i - 1;
else
temp = i;
for (j = 0; j <= temp; j++)
printf("%c", symbol--);
}
printf("\n\n\n");
// More Optimised
// Approach
int l, m;
for(i=0;i<=6;i++)
{
for(k=65;k<=71-i;k++)
printf("%c", k);
for(j=1;j<=i*2-1;j++)
printf(" ");
for(l=71-i;l>=65;l--)
if(l != 71)
printf("%c", l);
printf("\n");
}
return 0;
}