查找A數組中某值與B中某值等值

#include
using namespace std;


void matching(int a[],int b[],int k)
{


int i=0;
while (i <= k-1)
{
int j=0;
while ( j <= k-1)
{
if (a[i] == b[j])
{
cout << "a[" << i << "]" << "match" << "b["<<j<<"]" <<endl;


break;
}
j++;
}
i++;
}
cout << endl;
}


int main()
{
int a[10] = {1,2,3,4,5,6,7,8,9,10};
int b[10] = {10,6,4,5,1,8,7,9,3,2,};
int k= sizeof(a)/sizeof(int);
matching(a,b,k);
return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章