004-006-002

配列コピー:レシピ材料リスト

初級

問題説明

配列コピー:レシピ材料リスト

この問題では: 入力された材料名を文字列配列に格納し、別の配列にコピーして、元の配列とコピーした配列を並べて表示するプログラムを作成します。

学習目標: 文字列配列の要素を別の配列にコピーできる

料理レシピの材料リストを管理します。元のレシピ材料を新しい配列にコピーして、2つのリストを並べて表示します。

入力

1行目: 材料の数n(1~5)
2行目以降: 材料名(n個)

出力

=== Recipe Ingredients ===
Original Recipe:
1. [材料1]
2. [材料2]
...

Copied Recipe:
1. [材料1]
2. [材料2]
...

Total Ingredients: [n]個
```java

## 具体例

### 例1: 3つの材料をコピー
入力:
```java
3
卵
牛乳
砂糖
```java
出力:
```java
=== Recipe Ingredients ===
Original Recipe:
1. 卵
2. 牛乳
3. 砂糖

Copied Recipe:
1. 卵
2. 牛乳
3. 砂糖

Total Ingredients: 3個

テストケース例

※ 出力例はプログラミングの国際標準に準拠し英語で表示しています

入力:
3
Egg
Milk
Sugar
期待される出力:
=== Recipe Ingredients ===
Original Recipe:
1. Egg
2. Milk
3. Sugar

Copied Recipe:
1. Egg
2. Milk
3. Sugar

Total Ingredients: 3 items
入力:
2
Butter
Flour
期待される出力:
=== Recipe Ingredients ===
Original Recipe:
1. Butter
2. Flour

Copied Recipe:
1. Butter
2. Flour

Total Ingredients: 2 items
入力:
1
Salt
期待される出力:
=== Recipe Ingredients ===
Original Recipe:
1. Salt

Copied Recipe:
1. Salt

Total Ingredients: 1 items
入力:
2
Rice
Water
期待される出力:
=== Recipe Ingredients ===
Original Recipe:
1. Rice
2. Water

Copied Recipe:
1. Rice
2. Water

Total Ingredients: 2 items
❌ テストに失敗したケースがあります
❌ エラー発生

あなたの解答

現在のモード: 自分のコード
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// ここにコードを書いてください

sc.close();
}
}
0 B / 5 MB

残り 9 回実行可能