开发者

How to compare two vectors, in C++

开发者 https://www.devze.com 2023-01-01 03:07 出处:网络
This is my code: #include <algorithm> void f() { int[] a = {1, 2, 3, 4}; int[] b = {1, 2, 100, 101};

This is my code:

#include <algorithm>
void f() {
    int[] a = {1, 2, 3, 4};
    int[] b = {1, 2, 100, 101};
    // I want to do something like this:
    // int* found = compare(a[0], a[3], b[0]);
    // in order to get a pointer to a[2]
}

Maybe I missed this algorithm in the manual… Plea开发者_JAVA百科se help :)


Look at std::mismatch


Sort your array and use mismatch.

0

精彩评论

暂无评论...
验证码 换一张
取 消