but how do i reverse a string if it isnt a string? which means how do i avoid using pointers and arrays m confused
81 Replies - 21101 Views - Last Post: 27 February 2013 - 11:18 PM
#77
Re: A little challenge: "Reverse a string"
Posted 28 November 2012 - 08:54 AM
most of the solutions that stayed within the confines of the challenge found an alternate representation for a string.
#78
Re: A little challenge: "Reverse a string"
Posted 12 January 2013 - 10:17 AM
I believe this works. I didn't know if string member functions are allowed. But here is my solution. It works!
Spoiler
#79
Re: A little challenge: "Reverse a string"
Posted 12 January 2013 - 05:16 PM
Quote
I believe this works. I didn't know if string member functions are allowed. But here is my solution. It works!
The problem states that you are required NOT to use arrays, pointers, or C strings. Well you are using C++ strings so I think your not very creative solution passes.
#80
Re: A little challenge: "Reverse a string"
Posted 12 January 2013 - 05:34 PM
jjl, on 12 January 2013 - 05:16 PM, said:
Quote
I believe this works. I didn't know if string member functions are allowed. But here is my solution. It works!
The problem states that you are required NOT to use arrays, pointers, or C strings. Well you are using C++ strings so I think your not very creative solution passes.
I don't think it's a question of creativity but does it solve the problem. And my solution solves the problem.
#81
Re: A little challenge: "Reverse a string"
Posted 16 February 2013 - 12:08 AM
I haven't got the code yet, but not using the reverse function, I would use recursion, grabbing one letter, then calling itself, then printing the letter. Am not 100% sure how I would grab the letter yet, but im going to try
#82
Re: A little challenge: "Reverse a string"
Posted 27 February 2013 - 11:18 PM
Spoiler
This post has been edited by Skydiver: 28 February 2013 - 06:19 AM
Reason for edit:: Fixed tags.
|
|

New Topic/Question
Reply



MultiQuote







|