package com.loveCoding.homework.j20250517_method;

import java.util.Arrays;

/**
 * @author WanJl
 * @version 1.0
 * @title T7
 * @description **6. 合并两个数组**
 * 要求：将两个等长的数组合并为一个新数组，交替存储元素
 * 示例输入：`{1,3,5}` 和 `{2,4,6}`
 * 示例输出：`1 2 3 4 5 6`
 * @create 2025/5/24
 */
public class T6 {
    public static void main(String[] args) {
        int[] subArr1 = {1, 3, 5};
        int[] subArr2 = {2, 4, 6};
        int[] arr = new int[subArr1.length + subArr2.length];
        for (int i = 0; i < subArr1.length; i++) {
            arr[2*i] =subArr1[i];
            arr[2*i+1] =subArr2[i];
        }
        System.out.println(Arrays.toString(arr));
    }
}
