1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include <iostream>
using namespace std;
bool isreflexive(int ar[],int n,int ar2[],int nn)
{
int j,i = 0;
cout<<"n " <<n<<endl;
for(i = 0; i <n-1; i++)
{
cout<<"i "<<i<<endl;
if(ar[i] == ar2[j])
{
cout<<"match"<<endl;
j++;
}
else
{
cout<<"not a match"<<endl;
j++;
}
}
}
int main()
{
int ar[] = {1,2,3,4,4,7,7 };
int ar2[] = {1,2,3,4,7,4,7};
int n = sizeof(ar)/sizeof(int);
int nn = sizeof(ar2)/sizeof(int);
cout<<n<<endl;
if( isreflexive(ar,n, ar2,nn))
{
cout<<"is reflexive"<<endl;
}
else
{
cout<<"is not reflexive"<<endl;
}
}
|