// reads an array length and char array and determines if it is a palindrome // CS1711 class, 197 November 7 #include #include const int MAXPAL=50; //maximum array size for the palindrome void fill_array(char a[], int a_size, int& a_used); // fills a character array of size a_size with a_used entries // based on a function from the text int palcheck(const char a[], int asize, int alength); /* a is a character array of size asize with alength items filled return 1 if a contains a palindrome, else 0 */ void out_char_arr(char a[], int asize, int alength); /* a is a character array of size asize with alength items filled the array is sent to the output stream */ main() { int pal_len,count = 0; char pal[MAXPAL]; cout << "What is the length of your palindrome?\n"; cin >> pal_len; while ((pal_len > MAXPAL)||(pal_len < 0)) //error trap { if (count > 3) {cout << "Too many bad inputs, exiting now..."; exit (1);} else {count++; cout << "Too long or short, try again...\n"; cin >> pal_len;};}; //while fill_array(pal,MAXPAL,pal_len); cout << "\n\n The string of characters: \n"; out_char_arr(pal,MAXPAL,pal_len); if (palcheck(pal,MAXPAL,pal_len)) cout << "\n The string is a palindrome"; else cout << "\n The string is a not a palindrome"; return 0; } void fill_array(char a[], int size, int& number_used) { int index = 0; char next; cout << "Type in the appropriate number of letters\n"; do { // while index cin >> next; a[index] = next; index++; } while (index < number_used); number_used = index; } int palcheck(const char a[], int asize, int alength) { const int TRUE=1, FALSE=0; int front, back, found; front=0; back=alength-1; found=TRUE; while((front