문제

I would like to zip two arrays in C++ (as in Python) using a standard library function, so is there any equivalent for Python's built-in function zip()?

도움이 되었습니까?

해결책

int **zip(int *arr1, int *arr2, int length)
{
    int **ret = new int*[length];
    for(int i = 0; i<length; i++)
    {
        ret[i] = new int[2];
        ret[i][0] = arr1[i];
        ret[i][1] = arr2[i];
    }
    return ret;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top