当前位置: 首页 > 面试经验 >

2022-09-06-虹软C++一面-已挂

优质
小牛编辑
102浏览
2023-03-28

2022-09-06-虹软C++一面-已挂

难道是忘了发他们的面试帖子挂了?

static int *f()
{
    int a = 1;
    a = a + 1;
    return &a;
}

int main()
{
    int *q = NULL;
    q = f();
    cout << *q << "\n";
    return 0;
}

看代码,
问这有没有什么问题

问了我好几次问我会不会深度学习、图像处理、cv、opencl、YUV

https://www.jianshu.com/p/f00118464b03

问了上面的图片里的代码怎么做加速,说了一些,还要继续说,没说到点子上

二分搜索。。一开始还写错了,测试才发现,while里加了个等于号或者后面加个if

#include <vector>
#include <iostream>
using namespace std;

bool bisearch(const vector<int> &a, int target)
{
    int l = 0, r = a.size() - 1, mid;
    while (l <= r)
    {
        mid = (l + r) / 2;
        if (a[mid] == target)
            return true;
        else if (a[mid] > target)
            r = mid - 1;
        else
            l = mid + 1;
    }
    // if (a[l] == target || a[r] == target)
    //     return true;
    return false;
}

int main()
{
    vector<int> a(5);
    a[0] = 1, a[1] = 5, a[2] = 8, a[3] = 9, a[4] = 11;
    int target = 6;
    if (bisearch(a, target))
    {
        cout << "found " << target << "\n";
    }
    else
    {
        cout << target << " not found in array a\n";
    }
    return 0;
}
#虹软##虹软科技##23届秋招笔面经##23秋招#
 类似资料: