小编Ami*_*ish的帖子

在递归中使用 return 与不返回?

这是使用递归反转数组的代码

使用return rev(arr,++start,--end);

#include <iostream>
using namespace std;

void rev(int arr[],int start,int end)
{
    if(start >= end)
    {
        return;
    }
    int temp = arr[start];
    arr[start] = arr[end];
    arr[end] = temp;
    return rev(arr,++start,--end);
}

void reverse(int arr[],int size)
{
    rev(arr,0,size-1);
}
Run Code Online (Sandbox Code Playgroud)

使用rev(arr,++start,--end);

void rev(int arr[],int start,int end)
{
    if(start >= end)
    {
        return;
    }
    int temp = arr[start];
    arr[start] = arr[end];
    arr[end] = temp;
    rev(arr,++start,--end);
}

void reverse(int arr[],int size)
{
    rev(arr,0,size-1);
}
Run Code Online (Sandbox Code Playgroud)

它们都给出相同的输出7 6 5 4 …

c++ recursion return

5
推荐指数
1
解决办法
106
查看次数

OpenCV 和 Scipy.fftpack.dctn 的 DCT 输出不同?

我正在计算尺寸为 32x32 的灰度图像的 DCT

  • 使用 OpenCV
def _dct(image):
    result = cv2.dct(np.float32(image)/255.0)
    return (result * 255.0)
Run Code Online (Sandbox Code Playgroud)
  • 使用 Scipy.fftpack.dctn
dctn(image)
Run Code Online (Sandbox Code Playgroud)

首先使用cv2.dct()然后使用scipy.fftpack.dctn()输出两个函数 输出

python opencv dct scipy

2
推荐指数
1
解决办法
331
查看次数

标签 统计

c++ ×1

dct ×1

opencv ×1

python ×1

recursion ×1

return ×1

scipy ×1