I need to compress a string to find out if a word is a palindrome (same as reversed like race car). So I also need to do the reverse of it. I only missed one class and the notes are online and she never went over this and I can't find it in the book. When I search it on google I get something completely different.
example:
Enter a sentence to check:
Ten animals I slam in a net.
compressed: tenanimalsislaminanet
reversed: tenanimalsislaminanet
===> Palindrome!!!
The things I need help with is compressing a sentence, taking out the punctuation, and reversing it. The only problem is I have to use only what we've learned so far so be as basic as possible please.
string input
string compressed := ""
for each char c in input
if c != ' ' and c != ',' and c != '.' end etc. then
append c to compressed
If you're working with arrays of characters, to append you'll need a variable j to mark the end of compressed. Write compressed[j] = c; j++;. Don't forget to append a 0 after the loop.