我想找到兩個數組之間的公共元素。我的功能無法正常工作。 數組已排序。 只是想將兩個有序數組放入check_common函數中以顯示常見元素。 任何人都可以幫助解決它請!兩個數組之間的通用函數?
void check_common (int x[], int size1, int y[], int size2)
{
int temp;
cout << " Common elements are:\t" << endl;
for (int i=0; i <= size2; i++)
{
for (int j=0; j <= size1; j++)
{
if (x[j] == y[j]){
temp = x[j];
cout << temp << "\t";}
}
}
cout << endl;
}
我不確定你在問什麼。 – dutt
'for(int i = 0; i
mah