Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Problem regarding FUNCTION within the C and C++ forums, part of the Software Development category; Help solve a problem regarding FUNCTION What the followng function is doing: string f(const string &x) { return x.empty()? x : f(x.substr(1)) + x[0]; } Guys - Please help solve ...
|
|||||||
|
|||
|
Problem regarding FUNCTION
Help solve a problem regarding FUNCTION
What the followng function is doing: string f(const string &x) { return x.empty()? x : f(x.substr(1)) + x[0]; } Guys - Please help solve this problem. Appreciate it. |
| Sponsored Links |
|
|||
|
Re: Problem regarding FUNCTION
Hi Heidi,
This is my analysis: Take the string HEIDI. The first time the function will be called with f("HEIDI") Quote:
The above statement can be read as: return f("EIDI") + "H" The next time it is called the statement becomes return f("IDI") + "E" and so on.... Esentially, this function will reverse the string passed to it. Assumptions: The substring method returns the substring from the index to the end of the string. Regards, Sahil. --Smile, it makes people wonder what you are thinking. ![]() |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| function | goutham_konduru | Oracle | 1 | 12-11-2007 03:23 AM |
| What is the use of abs function | Geek_Guest | QTP | 1 | 07-23-2007 07:29 AM |
| throwexception from function to function | JobHelper | VB.NET | 1 | 06-25-2007 07:24 AM |
| TSL Function | sutnarcha | WinRunner | 1 | 12-20-2006 05:40 AM |
| Function in PHP | sripri | PHP | 1 | 07-20-2006 12:13 PM |