回答編集履歴

2

渦巻のコードの追加

2019/07/03 17:36

投稿

kazuma-s
kazuma-s

スコア8224

test CHANGED
@@ -63,3 +63,65 @@
63
63
  ```
64
64
 
65
65
  "■" は全角文字なので、x は 2ずつ増えたり減ったりします。
66
+
67
+ ### 追記
68
+
69
+ 渦巻状に四角形の中を埋めていくのかな?
70
+
71
+ ```C
72
+
73
+ #include <stdio.h> // printf
74
+
75
+ #include <windows.h> // SetConsoleCursorPosition, GetStdHandle, Sleep
76
+
77
+
78
+
79
+ void locate(int x, int y)
80
+
81
+ {
82
+
83
+ COORD coord = { x, y };
84
+
85
+ SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
86
+
87
+ }
88
+
89
+
90
+
91
+ void plot(int x, int y)
92
+
93
+ {
94
+
95
+ locate(x, y); printf("■"); Sleep(100);
96
+
97
+ }
98
+
99
+
100
+
101
+ int main(void)
102
+
103
+ {
104
+
105
+ system("cls");
106
+
107
+ int top = 2, bottom = 13, left = 5, right = 26;
108
+
109
+ for (; top < bottom; top++, bottom--, left += 2, right -= 2) {
110
+
111
+ int x = left, y = top;
112
+
113
+ for (; y < bottom; y++) plot(x, y);
114
+
115
+ for (; x < right; x += 2) plot(x, y);
116
+
117
+ for (; y > top; y--) plot(x, y);
118
+
119
+ for (; x > left; x -= 2) plot(x, y);
120
+
121
+ }
122
+
123
+ locate(0, 15);
124
+
125
+ }
126
+
127
+ ```

1

サイズ変更

2019/07/03 17:35

投稿

kazuma-s
kazuma-s

スコア8224

test CHANGED
@@ -28,7 +28,7 @@
28
28
 
29
29
  system("cls");
30
30
 
31
- int top = 2, bottom = 13, left = 5, right = 30;
31
+ int top = 2, bottom = 13, left = 5, right = 26;
32
32
 
33
33
  int x = left, y = top;
34
34
 
@@ -44,13 +44,13 @@
44
44
 
45
45
  }
46
46
 
47
- for (; y >= top; y--) {
47
+ for (; y > top; y--) {
48
48
 
49
49
  locate(x, y); printf("■"); Sleep(100);
50
50
 
51
51
  }
52
52
 
53
- for (; x >= left; x -= 2) {
53
+ for (; x > left; x -= 2) {
54
54
 
55
55
  locate(x, y); printf("■"); Sleep(100);
56
56