终端图形
300 words
2 minutes
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
|
//c
#include <stdio.h>
#define Row 21
int arry[Row][Row];
void init_arry()
{
for (int i = 0; i < Row; i++)
{
for (int j = 0; j < Row; j++)
{
arry[i][j] = 0;
}
}
}
void func()
{
int mid = Row / 2;
int left = mid;
int right = mid;
int flag = 0;
for (int i = 0; i < Row; i++)
{
if (i == 0 || i == Row - 1) //
{
arry[i][mid] = 1;
}
else
{
if (flag)
{
left++;
right--;
}
else
{
left--;
right++;
}
arry[i][left] = 1;
arry[i][right] = 1;
if (left == 0 && right == Row - 1)
{
flag = 1;
}
}
}
}
void print()
{
for (int i = 0; i < Row; i++)
{
for (int j = 0; j < Row; j++)
{
if (arry[i][j] == 0)
{
printf(" ");
}
else
{
printf("*");
}
}
printf("\n");
}
}
int main()
{
init_arry();
func();
print();
}
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*
|