Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please don't use ioStream. We are given the input through stdin (C program) Problem B: Longest Palindrome Joe Coder is working on a project that
Please don't use ioStream. We are given the input through stdin (C program)
Problem B: Longest Palindrome Joe Coder is working on a project that involves collecting palindromes. If you did not know, a palindrome is a word that reads the same backward as forward. For example, words such as 'noon', level, or "radar, are palindromes. Some phrases are also palindromes, such as race car. taco cat', 'never odd or even, or 'was it a car or a cat i saw'. In his search for long palindromes, Joe collected a large textual corpus and you task is to write a program to help him. He already removed all characters other than letters from these texts, and changed all letters into lower case, so you do not need to worry about that. He organi candidate pieces of text into lines, where each line contains a sequence of lowercase letters. Most of these lines are not palindromes, but Joe is looking for a longest substring that is a palindrome i.e., a longest sequence of consequtive letters that do form a palindrome. For example, if the word zed his monotonously' is given, then the longest palindrome substring is onotono' and it is a part of the word as follows: 'monotonously nput You program must read the standard input and you can assume that all lines that Joe collected ane not longer than 1000 letters. You should stop when you reach the end of the standard input. You can assume that each line consists of a sequence of lowercase letters. If there are any empty lines, they should be ignored. Output For each input line, you program must produce one output line, reporting the maximal length palindrome substring. If there are more than one such substrings, then the leftmost one must be reported. The format of the output line must be word-line) maxpa1=n (pal) where line is the original line, n is the length of the maximal palindrome substring, and pal is the leftmost such palindrome substring (You can take a look at the sample input and output on the next page.)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started