add one more thing - its batter as long as storage is not restricted in size - which would be the ONLY case/reason i would use recursion.
--- David Fleury <[EMAIL PROTECTED]> wrote: > > > > -----Message d'origine----- > > De : [email protected] > [mailto:[EMAIL PROTECTED] De la part de > > Mickey Mathieson > > Envoyé : vendredi 16 mars 2007 13:35 > > À : [email protected] > > Objet : Re: [c-prog] Recursion - Reverse String > Example > > > > > > There was a question in a previous post. I don't > > recall using all caps - maybe a few words were > caps > > but never the complete sentences. > > > > as far as challenging people - if they could come > up > > with a better solution (with out changing calling > > convention) then lets see it. I don't see the > problem > > in this. > > > It was not clear that you can't change the main > function declaration > (convention? Firstly I thought about stdcall, ... ) > Just for fun... RevStr did not change but call a > better recursive > function mostly for storing the initial string size. > > > char* reverse_r( char*, char* ); > > char *RevStr(int count, char *str) > { > return reverse_r( str, str + count - 1 ); > } > > char* reverse_r( char* begin, char* end ) > { > if ( end <= begin ) return begin; > char c = *end; *end = *begin; *begin = c; //swap > reverse_r( begin+1, end-1 ); > return begin; > } > > Regards, > David > > > > ---------- > > Ce message et ses pièces jointes (le "message") est > destiné à l'usage > exclusif de son destinataire. > > Si vous recevez ce message par erreur, merci d'en > aviser immédiatement > l'expéditeur et de le détruire ensuite. Le présent > message pouvant > être altéré à notre insu, CALYON Crédit Agricole > CIB > ne peut pas être engagé par son contenu. Tous droits > réservés. > > This message and/or any attachments (the "message") > is intended for > the sole use of its addressee. > > If you are not the addressee, please immediately > notify the sender and > then destroy the message. As this message and/or > any attachments may > have been altered without our knowledge, its > content is not legally > binding on CALYON Crédit Agricole CIB. All rights > reserved. > > > > [Non-text portions of this message have been > removed] > > ____________________________________________________________________________________ TV dinner still cooling? Check out "Tonight's Picks" on Yahoo! TV. http://tv.yahoo.com/
