我有兩個整數「a」和「b」數組。我想查找一個[0],a [1]等是否也在b []中。我曾經嘗試這樣做:在c中的另一個數組中找到一個數組的一個元素
int emfanisi(int a[], int b[], int x){
int i, j;
for(i=0; i<x; i++)
{
for(j=0; j<x; j++)
{
if(a[i] = b[j])
{
return 1;
}
else
{
return 0;
}
}
}
}
在主要我這樣做:
for(i=0; i<2; i++){
pos = 0;
pos = emfanisi(a,b,2);
if(pos = 1)
printf("The %d number shows in the second array\n", i+1);
else
printf("The %d number doesnt show in the second array\n", i+1);
}
但這似乎並沒有工作!
有人能指出我的錯誤嗎?
這似乎不工作。 – dothedos
@dothedos,與'pos'類似的問題更新。 – hmjd