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
|
int arr[] = {1,1,2,2,3,3,4,4,5,5};
int arm[] = {1,2,3,4,5};
int arr2[] = {1, 1, 2, 2, 3, 3, 4, 4, 4, 7, 7, 4, 7, 7};
int arm2[] = {1,2,3,4,7};
int arr3[] = {1, 1, 2, 4, 3, 9, 4, 16, 5, 25, 6,36, 7, 49, 8, 64};
int arm3[] = {1,2,3,4,9,16,5,25,6,36,7,49,8,64};
int n = sizeof(arm)/sizeof(int);
int nn = sizeof(arr)/sizeof(int);
int n2 = sizeof(arm2)/sizeof(int);
int nn2 = sizeof(arr2)/sizeof(int);
int n3 = sizeof(arm3)/sizeof(int);
int nn3 = sizeof(arr3)/sizeof(int);
bool pair_exist(int left, int right, int b[], int nn)
{
for (int i=0; i<nn; i+=2)
{
if (left==b[i] && right==b[i+1]) return true;
}
return false;
}
bool symmetric(int arr[],int nn)
{
for(int i=0;i<nn;i+=2)
{
int e = arr[i];
int f = arr[i+1];
cout<<"f " <<f<<endl;
cout<<"e " <<e<<endl;
if(!pair_exist(e,f,arr,nn))
return false;
}
return true;
}
|