PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > how can I puts a char array reserve by recursion algoritym?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
how can I puts a char array reserve by recursion algoritym?

Réponse
 
LinkBack Outils de la discussion
Vieux 23/11/2007, 19h53   #1
emre esirik(hacettepe computer science and engineering)
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut how can I puts a char array reserve by recursion algoritym?

int i=0;
char word[50];
printf("enter the word");
scanf("%s",word);
reserve(word,i);

void reserve(char word[], int i)
{
if(word[i]!='\0')
{
reserve(&word[i+1],i+1);
printf("%c",word[i+1]);
}
}
  Réponse avec citation
Vieux 23/11/2007, 21h56   #2
Eric Sosman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how can I puts a char array reserve by recursion algoritym?

emre esirik(hacettepe computer science and engineering) wrote:
> int i=0;
> char word[50];
> printf("enter the word");
> scanf("%s",word);
> reserve(word,i);
>
> void reserve(char word[], int i)
> {
> if(word[i]!='\0')
> {
> reserve(&word[i+1],i+1);
> printf("%c",word[i+1]);
> }
> }


Solution #1: Suppose the word is just one letter long,
or is the zero-letter word "". Can you think of a way to
reverse it? Good! Now suppose you know how to reverse words
of N letters. Can you use that method along with a few other
simple operations to reverse a word of N+2 letters? (Hint:
write N+2 as 1+N+1.)

Solution #2: If you always use words like EWE or NOON
or MADAM or DENNED or DEIFIED or REDIVIDER, the program will
be fairly simple.

Remark: I cannot imagine why anyone would want to use
recursion for this problem, but ...

--
Eric Sosman
esosman@ieee-dot-org.invalid
  Réponse avec citation
Vieux 23/11/2007, 22h09   #3
Walter Roberson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how can I puts a char array reserve by recursion algoritym?

In article <9dKdnZaZCfod0dranZ2dnUVZ_gSdnZ2d@comcast.com>,
Eric Sosman <esosman@ieee-dot-org.invalid> wrote:

> Solution #2: If you always use words like EWE or NOON
>or MADAM or DENNED or DEIFIED or REDIVIDER, the program will
>be fairly simple.


> Remark: I cannot imagine why anyone would want to use
>recursion for this problem, but ...


We've seen it before several times, as a homework problem.

..melborp krowemoh a sa ,semit lareves erofeb ti nees ev'eW
--
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth
  Réponse avec citation
Vieux 24/11/2007, 21h46   #4
Barry Schwarz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how can I puts a char array reserve by recursion algoritym?

On Fri, 23 Nov 2007 11:53:31 -0800 (PST), "emre esirik(hacettepe
computer science and engineering)" <emreesirik@gmail.com> wrote:

Your question was answered in response to your post in
alt.comp.lang.learn.c-c++. Please don't post separate questions in
different newsgroups. If you must post to multiple groups, post a
single message to all the groups by using multiple addresses.


Remove del for email
  Réponse avec citation
Vieux 26/11/2007, 09h32   #5
Charlie Gordon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how can I puts a char array reserve by recursion algoritym?

"emre esirik(hacettepe computer science and engineering)"
<emreesirik@gmail.com> a écrit dans le message de news:
17651794-5cfe-490a-9780-0107dee5e579...oglegroups.com...
> int i=0;
> char word[50];
> printf("enter the word");
> scanf("%s",word);
> reserve(word,i);
>
> void reserve(char word[], int i)
> {
> if(word[i]!='\0')
> {
> reserve(&word[i+1],i+1);
> printf("%c",word[i+1]);
> }
> }


Try harder! You are off by one on about every line ;-)
I have reversations with your choice of algorithm.

--
Chqrlie.


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h56.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13000 seconds with 13 queries