Help with Palindromic List

I would like to know how I can write a function to determine if the list read in from the bellow code is palindromic? e.g if say the list of numbers is 123456 the program will print out "This list is not a palindrome" and if the list is say 12321 then it would print out "This list is a palindrome".

any help would be appreciated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void popArray(int array1[]) {
    ifstream infile("TEST1.TXT");
    if (!infile) {
        cout << "Can't open file: " << endl;
        exit(EXIT_FAILURE);
    }
    for (int i = 0; i < 10; i++) {
        infile >> array1[i];
        cout << setw(2) << array1[i];
    }
}
void reverseList(int array1[]) {
    for (int x = 9; x > -1; x--) {
        cout << setw(2) << array1[x];
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const int ARRAYSZ = 9 ;
int array[ARRAYSZ] = { 1, 2, 3, 4, 5, 4, 3, 2, 1 } ;

// check if sequence is a pandrome

int left = 0 ; // first position on the left
int right = ARRAYSZ - 1 ; // last position on the right

for( ; left < right ; ++left, --right )
{
     // TODO:
     // if ...
     // {
            // ...
     // }
}
Topic archived. No new replies allowed.