Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void searchForPalindrom(int* arr, int size, int& watch)
- {
- int bufi = 0, bufj = 0, j = 0;
- bool isPalindrom = true;
- for (int i = 0; i < size; ++i)
- {
- j = size - 1;
- if (arr[i] == arr[j])
- {
- bufi = i;
- bufj = j;
- isPalindrom = true;
- while (bufi != bufj && isPalindrom)
- {
- if (arr[bufi] != arr[bufj])
- {
- isPalindrom = false;
- }
- ++bufi;
- --bufj;
- }
- if (isPalindrom && i != j)
- {
- cout << i+1 << " " << j+1 << endl;
- ++watch;
- }
- }
- }
- if (j > 0)
- {
- searchForPalindrom(arr, size - 1, watch);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment