Question: The program shall read, from standard input, an arbitrary number of whitespace - delimited tokens, trimmed at both ends of any characters for which (
The program shall read, from standard input, an arbitrary number of whitespacedelimited tokens, trimmed at both ends of any characters
for which std: : isalpha returns false. Each such token will constitute a word. You may assume that the total number of input words
does not exceed the capacity of the int type on our server.
A word shall be considered a palindrome if:
Its length is greater than
Its sequence of characters is the same forward and backward, without regard to case. eg the name t to shall be considered a
palindrome.
The program shall print, to standard output, two or three lines, in the following order, summarizing the input:
A line containing the total number of words, printed as a decimal integer
A line containing the total number of palindromes, printed as a decimal integer
A line containing the longest palindrome ie the palindrome with the greatest length
a If there is a tie for longest palindrome, choose the first occurrence.
b This third line shall be printed if and only if the input contains one or more palindromes.
The format of your output lines can be freeform, but make sure that the only decimal numbers contained in lines and are the relevant numbers
of words and palindromes.
Sample executable:
Command:
cslongestpalindrome "You might be a Nauruan if you're from Nauru."
Command:
cslongestpalindrome
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
