Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/128.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何比较两个向量,用C++;_C++ - Fatal编程技术网

C++ 如何比较两个向量,用C++;

C++ 如何比较两个向量,用C++;,c++,C++,这是我的代码: #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] } #包括 void f()

这是我的代码:

#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]
}
#包括
void f(){
int[]a={1,2,3,4};
int[]b={1,2100,101};
//我想这样做:
//int*found=compare(a[0],a[3],b[0]);
//为了获得指向[2]的指针
}

可能我在手册中遗漏了这个算法……请帮助:)

您的数组和使用。

查看
int[]a
?C++代码在哪里?你的意思是“比较两个向量”还是“比较两个数组”。你是想找出两个数组上最后一个匹配的索引吗?若第一个元素不匹配,你们会返回一个错误码或0?我认为这是数组,不是向量。