|
Prev: how to parse a csv file of decimal numbers?
Next: I am learning recursion, but I couldnt find my wrong,can u helpme?
From: emre esirik(hacettepe com. sci. and eng.) on 23 Nov 2007 14:02 I am trying to reserve a word with using recursion algoritim,but it only puts first capital of the word, why doesnt it puts exactly word?,can you help me? #include <stdio.h> void reserve(char [], int); int main(int c,char *argv[]) { char word[50]={0}; int i=0,end_str; scanf("%s",word); for(i=0;i<50;i++) { if(word[i]=='\0') { end_str=i; break; } } reserve(word,end_str-1); return 0; } void reserve(char word[],int i) { if(i!=0) { printf("%c", word[i]); reserve(&word[i-1],i-1); }else{ printf("\n"); } }
From: Simon. (Zed Argh Seven) on 23 Nov 2007 16:10 on Fri, 23 Nov 2007 11:02:37 -0800 (PST), "emre esirik(hacettepe com. sci. and eng.)" <emreesirik(a)gmail.com> wrote this wisdom: >Henry wrote: > >> I'm running WinXP home ed with NTFS. All was OK until I turned on the >> machine today. I got the post beep and it started to launch. It >> suddenly stopped and gave me the following error: >> >> Windows could not start because the following file is missing or corrupt: >> >> \WINDOWS\SYSTEM32\CONFIG\SYSTEM >> >> That's all. There was no file name at the end. I tried a complete SYSTEM *IS* the filename that windows is complaining about. Files don't HAVE to have an extention after the name You may have a SYSTEM.ALT which I think would be the backup to SYSTEM (I see one under windows 2000 so I assume it's the backup) >> shutdown, but I got the same results. I tried three times and that's >> as far as it would go. I downloaded The Ultimate Boot CD and burned >> it and tried to use it and it wouldn't even boot to that. >> Did you burn the UBCD as an iso image ? or did you copy the iso image onto the CD? (They produce two quite different things) >> Anyone know what's happening? Am I toast? >> >You may try F8 and "last known good". >Then, when you have the UBCD, you can let it run a filesystem check. >The "File" referred in the error messages means your system registry hive is >toast. Either due to ... well, registry corruption, or a filesystem flaw. -- Simon. 'Be Seeing You. Who is number one? I will not be pushed, filed, stamped, indexed, briefed, de-briefed or numbered. Registered Linux User #300464 Machine Id #188886 Linux Counter - http://counter.li.org/ Remove the s.p.a.m to reply -- Simon. 'Be Seeing You. Who is number one? I will not be pushed, filed, stamped, indexed, briefed, de-briefed or numbered. Registered Linux User #300464 Machine Id #188886 Linux Counter - http://counter.li.org/ Remove the s.p.a.m to reply
From: Simon. (Zed Argh Seven) on 23 Nov 2007 17:55
on Fri, 23 Nov 2007 21:10:13 GMT, "Simon. (Zed Argh Seven)" <sj_bradleyspam(a)blueyonder.co.uk> wrote this wisdom: Sorry - posted wrong message this is the correct one >I am trying to reserve a word with using recursion algoritim,but it >only puts first capital of the word, why doesnt it puts exactly >word?,can you help me? > I think you mean reverse not reserve >#include <stdio.h> >void reserve(char [], int); >int main(int c,char *argv[]) >{ > char word[50]={0}; > int i=0,end_str; > scanf("%s",word); > for(i=0;i<50;i++) > { > if(word[i]=='\0') > { > end_str=i; > break; > } > } Lets say the word you pass is say "fred" where word[0] = 'f' word[1] = 'r' word[2] = 'e' word[3] = 'd' end_str = 4 > reserve(word,end_str-1); > return 0; >} >void reserve(char word[],int i) what happens when you pass word[0] which is 'f' >{ > if(i!=0) Ah - here i now DOES =0 so skips printing the 'f' which I think you did want to print ... > { > printf("%c", word[i]); > reserve(&word[i-1],i-1); > }else{ > printf("\n"); > } >} try writing out a short word like "fred" and stepping through the code on paper and you should see the problem more clearly -- Simon. 'Be Seeing You. Who is number one? I will not be pushed, filed, stamped, indexed, briefed, de-briefed or numbered. Registered Linux User #300464 Machine Id #188886 Linux Counter - http://counter.li.org/ Remove the s.p.a.m to reply -- Simon. 'Be Seeing You. Who is number one? I will not be pushed, filed, stamped, indexed, briefed, de-briefed or numbered. Registered Linux User #300464 Machine Id #188886 Linux Counter - http://counter.li.org/ Remove the s.p.a.m to reply |