質問編集履歴

7

記述ミス

2023/02/07 11:07

投稿

mesii
mesii

スコア1

test CHANGED
File without changes
test CHANGED
@@ -25,9 +25,9 @@
25
25
  for (int i = 0; i < number; i++) {
26
26
  for (int j = 0; j < number; j++) {
27
27
  if(i == j) {
28
+ System.out.print("@");
29
+ } else {
28
30
  System.out.print("*");
29
- } else {
30
- System.out.print("•");
31
31
  }
32
32
  }
33
33
  System.out.println();

6

コンパイル後見直して修正できました。

2023/02/07 11:02

投稿

mesii
mesii

スコア1

test CHANGED
File without changes
test CHANGED
@@ -12,21 +12,27 @@
12
12
 
13
13
  制作中ですが、コードは下記です。
14
14
  ```
15
+
15
- import Java.until.Scanner;
16
+ import java.util.Scanner;
16
17
 
17
18
  public class Question07 {
18
19
  public static void main(String[] args) {
19
20
 
20
- Scanner hello = new Scanner(System.in);
21
+ Scanner scanner = new Scanner(System.in);
21
- System.out.println(整数を入力);
22
+ System.out.println("整数を入力");
22
23
 
23
- int number = hello.nextInt();
24
+ int number = scanner.nextInt();
24
25
  for (int i = 0; i < number; i++) {
25
26
  for (int j = 0; j < number; j++) {
27
+ if(i == j) {
26
- System.out.print(i == j ? ”@“ : ”);
28
+ System.out.print("");
29
+ } else {
30
+ System.out.print("•");
31
+ }
27
32
  }
33
+ System.out.println();
28
34
  }
29
- scanner.close
35
+ scanner.close();
30
36
  }
31
37
  }
32
- ‘’’
38
+

5

追加

2023/02/07 09:08

投稿

mesii
mesii

スコア1

test CHANGED
File without changes
test CHANGED
@@ -29,3 +29,4 @@
29
29
  scanner.close
30
30
  }
31
31
  }
32
+ ‘’’

4

インデント修正

2023/02/07 09:05

投稿

mesii
mesii

スコア1

test CHANGED
File without changes
test CHANGED
@@ -12,14 +12,20 @@
12
12
 
13
13
  制作中ですが、コードは下記です。
14
14
  ```
15
- public static void main(String[] args) {
15
+ import Java.until.Scanner;
16
16
 
17
+ public class Question07 {
18
+ public static void main(String[] args) {
19
+
17
- Scanner hello = new Scanner(System.in);
 System.out.println(“整数を入力“);
20
+ Scanner hello = new Scanner(System.in);

21
+ System.out.println(“整数を入力“);
22
+
18
- int number = hello.nextInt();
23
+ int number = hello.nextInt();
19
- for (int i=0 ; i<number ; i++){
24
+ for (int i = 0; i < number; i++) {
20
- for(int j=0 ; j<number ; j++){
25
+ for (int j = 0; j < number; j++) {
21
- System.out.print(i == j ?”@“:”*”);
26
+ System.out.print(i == j ? ”@“ : ”*”);
22
- }
27
+ }
28
+ }
29
+ scanner.close
30
+ }
23
31
  }
24
- scanner.close();
25
- }

3

nextInt()での記述変更

2023/02/07 04:50

投稿

mesii
mesii

スコア1

test CHANGED
File without changes
test CHANGED
@@ -7,6 +7,8 @@
7
7
  *@**
8
8
  **@*
9
9
  ***@
10
+
11
+
10
12
 
11
13
  制作中ですが、コードは下記です。
12
14
  ```

2

nextInt();で修正

2023/02/07 04:42

投稿

mesii
mesii

スコア1

test CHANGED
File without changes
test CHANGED
@@ -12,15 +12,12 @@
12
12
  ```
13
13
  public static void main(String[] args) {
14
14
 
15
- System.out.println(“整数を入力してください”);
16
- Scanner scanner = new Scanner (System.in);
 System.out.println(“整数を入力“);
15
+ Scanner hello = new Scanner(System.in);
 System.out.println(“整数を入力“);
17
- String inputStr = scanner.nextLine();
16
+ int number = hello.nextInt();
18
- int InputNum = Integer.parseInt(inputStr);
19
- for (int i=0 ; i<InputNum; i++){
17
+ for (int i=0 ; i<number ; i++){
20
- for (int j=0 ; j<InputNum; j++){
18
+ for(int j=0 ; j<number ; j++){
21
- System.out.print(i == j ?”@“ :*”);
19
+ System.out.print(i == j ?”@“:*”);
22
- }
20
+ }
23
21
  }
24
22
  scanner.close();
25
23
  }
26
- ```

1

コード表示

2023/02/07 03:42

投稿

mesii
mesii

スコア1

test CHANGED
File without changes
test CHANGED
@@ -9,7 +9,7 @@
9
9
  ***@
10
10
 
11
11
  制作中ですが、コードは下記です。
12
-
12
+ ```
13
13
  public static void main(String[] args) {
14
14
 
15
15
  System.out.println(“整数を入力してください”);
@@ -23,5 +23,4 @@
23
23
  }
24
24
  scanner.close();
25
25
  }
26
-
26
+ ```
27
-