如何確定一個數組是否包含在另一個數組中(按元素排序)?我曾在2010 MSVS編寫的程序之下,但也不太清楚如何完成布爾函數來確定一個陣列出現在另一個確定一個數組是否在另一個數組中包含
void isContained(int ar1[], int ar2[]);
int main(int argc, char** argv)
{
ifstream fin1("one.txt");
ifstream fin2("two.txt");
int i, j, value1, value2;
int arr1[ 10 ];
int arr2[ 10 ];
for (i = 0 ; fin1 >> value1 ; i++)
{
arr1[ i ] = value1;
}
for (j = 0 ; fin2 >> value2 ; j++)
{
arr2[ j ] = value2;
}
isContained(arr1, arr2);
system("PAUSE");
}
void isContained(int ar1[], int ar2[])
{
???
}
您可以使用''中的'std :: search'功能。標準庫中有很多有用的功能。您可能需要熟悉這些文檔。 –
Blastfurnace