Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool isReverseSubsequence(int* sequence, int startIndex, int endIndex, int size) {
- bool isCorrect;
- int i, j;
- i = startIndex;
- j = endIndex;
- while (i < j) {
- if (sequence[i] != sequence[j]) {
- isCorrect = false;
- exit;
- }
- i++;
- j--;
- }
- isCorrect = true;
- return isCorrect;
- }
- void findReversing(int* arr, int size, int& startIndex, int& endIndex) {
- int maxI, maxJ;
- maxI = startIndex;
- maxJ = startIndex;
- for (int i = startIndex; i <= endIndex; i++) {
- for (int j = i; j <= endIndex; j++) {
- if (isReverseSubsequence(arr, i, j, size)) {
- if ((j - i) > (maxJ - maxI)) {
- cout << "im = " << i << endl;
- cout << "jm = " << j << endl;
- maxI = i;
- maxJ = j;
- }
- }
- }
- }
- startIndex = maxI;
- endIndex = maxJ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement