回答編集履歴

1

ソースの訂正

2018/04/17 13:42

投稿

退会済みユーザー
test CHANGED
@@ -1,58 +1,50 @@
1
1
  こんにちは
2
2
 
3
- 幅17 高さ15を記号定数にして2重for文で書きましょう.
3
+ 2重for文で書きましょう.
4
4
 
5
5
 
6
6
 
7
- ```C
7
+ ```C#
8
8
 
9
- #include <stdio.h>
9
+ using System;
10
10
 
11
11
 
12
12
 
13
- #define WIDTH 17
13
+ public class Hello{
14
14
 
15
- #define HEIGHT 15
15
+ public static void Main(){
16
16
 
17
+
17
18
 
19
+ for(int i = 0; i < 15; i++){
18
20
 
19
- int main(void){
21
+ for(int j = 0; j < 17; j++){
20
22
 
21
-
23
+ if(i <= j && j <= i + 2){
22
24
 
23
- int i,j;
25
+ Console.Write("*");
24
26
 
25
-
27
+ }
26
28
 
27
- for(i = 0; i < HEIGHT; i++){
29
+ else if(14 - i <= j && j <= 16 - i){
28
30
 
29
- for(j = 0; j < WIDTH; j++){
31
+ Console.Write("*");
30
32
 
31
- if(i <= j && j <= i + 2){
33
+ }
32
34
 
33
- printf("*");
35
+ else{
34
36
 
35
- }
37
+ Console.Write(" ");
36
38
 
37
- else if(HEIGHT - 1 - i <= j && j <= WIDTH - 1 - i){
39
+ }
38
40
 
39
- printf("*");
41
+ }
40
42
 
41
- }
43
+ Console.WriteLine();
42
44
 
43
- else{
45
+ }
44
46
 
45
- printf(" ");
46
-
47
- }
47
+ }
48
-
49
- }
50
-
51
- printf("\n");
52
-
53
- }
54
-
55
- return 0;
56
48
 
57
49
  }
58
50