#include <iostream>
using namespace std;
bool same_elements(int a[], int b[], int size) {
bool ident = false;
for (int i = 0; i < size; i++) {
ident = true;
for (int j = 0; j < size; j++) {
if (a[j] != b[(j + i) % size]) ident = false;
}
if (ident) break;
}
return ident;
}
int main()
{
int a[] = { 1, 4, 9, 16, 9, 7, 4, 9, 11 };
int b[] = { 11, 1, 4, 9, 16, 9, 7, 4, 9 };
int c[] = { 11, 11, 7, 9, 16, 4, 1, 4, 9 };
if (same_elements(a, b, 9)) {
cout << "Arrays A and B are identical" << endl;
} else {
cout << "Arrays A and B are not identical" << endl;
}
if (same_elements(a, c, 9)) {
cout << "Arrays A and C are identical" << endl;
} else {
cout << "Arrays A and C are not identical" << endl;
}
// waiting for press ane key
cout << endl;
cout << "Press any key...";
cin.get();
return 0;
}
Comments
Leave a comment