Python's zip() equivalent in C or C++ [duplica

2019-06-23 22:37发布

This question already has an answer here:

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()?

1条回答
Deceive 欺骗
2楼-- · 2019-06-23 23:04
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;
}
查看更多
登录 后发表回答