Reference no: EM13163468
Half of the code is done. It's shown below, please follow as its starting and provide a simplicity code.
Palindrome Tester (C++)
Implement a function to recursively determine if a word is a palindrome. A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction. Famous examples include "Able was I ere I saw Elba", "A man, a plan, a canal: Panama".
Important questions to ask yourself:
- What is the base case?
- What is the recursive case?
The substr method of the string class will be useful. It takes the starting position of the first character to be copied as a substring and the number of characters to include in the substring.
Also useful is the length method. It returns the length of the string in question.
Examples:
string s = "defiant";
cout << s.substr(2, s.length()-4) << endl;
The above example prints out: fia
Here is some code to get you started. Submit your modified palindrome function. Do not modify the main function. When testing your function don't forget to type the word on the command line after "a.out": ./a.out radar
Starting...
#include <iostream>
#include <string>
using std::cout;
using std::endl;
using std::string;
bool palindrome(string);
int main(int argc, char *argv[]) {
string s = argc == 2 ? argv[1] : "redivider";
if (palindrome(s)) {
cout << "\"" << s << "\" is a palindrome." << endl;
}
else {
cout << "\"" << s << "\" is not a palindrome." << endl;
}
return 0;
}
bool palindrome(string w) {
// your code goes here
return false;
}
Display the array, the average and the number of days above
: Write a program that stores the daily temperatures for the month of April in an array name dailytemp. Calculate the average temperature for the month and the count the number of days that the daily temperature was above the average.
|
Simple java application that uses the string
: Create a simple Java application that uses the String class and/or the StringBuffer class and at least 4 of the class methods. Show the code, demonstrate it works properly and describe what it is doing.
|
Using unix extract the various ethnic populations in file
: Using Unix extract the various ethnic populations in your file.
|
Using array subscript notation
: Using array subscript notation, base/offset notation with the array name as the pointer, array notation with vPtr , and pointer/offset notation with vPtr , add 3 to the value in the 3 rd element and display that number. (Do not modify the value in ..
|
Implement a function to recursively
: Implement a function to recursively determine if a word is a palindrome. A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction.
|
. assume the node is in the usual info-link form with info
: Show what is produced by the following C++ code. Assume the node is in the usual info-link form with the info of the type int. (list, trail, and current are pointers of type nodeType.)
|
Prepare the journal entry to record depreciation expense
: Irons Delivery, Inc., purchased a new delivery truck for $42,000 on January 1, 2009. The truck is expected to have a $2,000 residual value at the end of its five-year useful life. Irons uses the straight-line method of depreciation.
|
Compute price and usage variances for direct materials
: Compute price and usage variances for direct materials and compute the direct labor rate and labor efficiency variances.
|
Find all irreducible polynomials
: Find all irreducible polynomials1. of degree 3 over GF(2),2. of degree 4 over GF(2).
|