teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

追記

2020/07/17 05:10

投稿

aaaajj
aaaajj

スコア5

title CHANGED
File without changes
body CHANGED
@@ -49,39 +49,6 @@
49
49
  }
50
50
  }
51
51
  }
52
- public static void main(String[] args) {
53
- int num1[] = new int[10];
54
- int num2[] = new int[10];
55
- int same[] = new int[10];
56
- int side[] = new int[10];
57
- System.out.print("配列1:");
58
- for (int i = 0; i < 10; i++) {
59
- num1[i] = (int) (Math.random() * 10) + 1;
60
- System.out.print(num1[i] + " ");
61
- }
62
- System.out.println(" ");
63
- System.out.print("配列2:");
64
- for (int i = 0; i < 10; i++) {
65
- num2[i] = (int) (Math.random() * 10) + 1;
66
- System.out.print(num2[i] + " ");
67
- }
68
- System.out.println("");
69
- System.out.println("共通の数:");
70
- for (int i = 0; i < 10; i++) {
71
- if (num1[i] == num2[i]) {
72
- same[i] = num1[i] = num2[i];
73
- System.out.print(same[i] + " ");
74
- }
75
- }
76
- System.out.println("");
77
- System.out.println("どちらかの数:");
78
- for (int i = 0; i < 10; i++) {
79
- if (num1[i] >= num2[i]) {
80
- side[i] = num1[i];
81
- System.out.print(side[i] + " ");
82
- }
83
- }
84
- }
85
- }
86
52
 
53
+
87
54
  ```

2

追記

2020/07/17 05:10

投稿

aaaajj
aaaajj

スコア5

title CHANGED
File without changes
body CHANGED
@@ -1,7 +1,11 @@
1
1
  ### 前提・実現したいこと
2
2
 
3
3
  2つの配列から、共通している数値とどちらかにしかない数値を表示させたいです。
4
-
4
+
5
+ 配列1: 4 9 4 3 6 8 7 1 3 10
6
+ 配列2: 7 3 10 7 5 9 4 9 9 1
7
+ 共通の数:1 3 4 7 9 10
8
+ どちらか入っている数:1 3 4 5 6 7 8 9 10
5
9
  ### 発生している問題・エラーメッセージ
6
10
 
7
11
  ```

1

修正

2020/07/17 05:09

投稿

aaaajj
aaaajj

スコア5

title CHANGED
File without changes
body CHANGED
@@ -5,7 +5,7 @@
5
5
  ### 発生している問題・エラーメッセージ
6
6
 
7
7
  ```
8
- 上手く表示されない
8
+ if文が正確に機能していないのか、期待している数値が表示されません。
9
9
  ```
10
10
 
11
11
  ### 該当のソースコード