<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>help a newb with recursion? - C++ - tribe.net</title>
  <link rel="alternate" href="http://cpp.tribe.net/thread/3eee7f5d-a883-4b77-ac1d-47f089051ba1?format=atom" />
  <subtitle>Tribe.net. Local Connections</subtitle>
  <entry>
    <title>Re: help a newb with recursion?</title>
    <link rel="alternate" href="http://CPP.tribe.net/thread/3eee7f5d-a883-4b77-ac1d-47f089051ba1#477ae237-7985-4cd6-96c9-20fafc3fa80d" />
    <author>
      <name>$item.owner.firstName</name>
    </author>
    <id>http://CPP.tribe.net/thread/3eee7f5d-a883-4b77-ac1d-47f089051ba1#477ae237-7985-4cd6-96c9-20fafc3fa80d</id>
    <updated>2004-07-24T18:54:12Z</updated>
    <published>2004-07-24T18:54:12Z</published>
    <summary type="html">Recursion is a lovely thing.  I do mostly php work, and squeed &#xD;
when the chance came up to write one, a database search for &#xD;
related entries omitting duplicate results.  Like as if you go to &#xD;
get your car fixed and the mechanic laughs and pulls out this &#xD;
really strange looking wrench.  Beautiful.</summary>
    <dc:creator>$item.owner.firstName</dc:creator>
    <dc:date>2004-07-24T18:54:12Z</dc:date>
  </entry>
  <entry>
    <title>Re: help a newb with recursion?</title>
    <link rel="alternate" href="http://CPP.tribe.net/thread/3eee7f5d-a883-4b77-ac1d-47f089051ba1#ecab2460-22de-4be1-a7f8-bf9c4677444d" />
    <author>
      <name>blank</name>
    </author>
    <id>http://CPP.tribe.net/thread/3eee7f5d-a883-4b77-ac1d-47f089051ba1#ecab2460-22de-4be1-a7f8-bf9c4677444d</id>
    <updated>2004-07-23T02:30:17Z</updated>
    <published>2004-07-23T02:30:17Z</published>
    <summary type="html">nevermind! i see what my problem is now</summary>
    <dc:creator>blank</dc:creator>
    <dc:date>2004-07-23T02:30:17Z</dc:date>
  </entry>
  <entry>
    <title>help a newb with recursion?</title>
    <link rel="alternate" href="http://CPP.tribe.net/thread/3eee7f5d-a883-4b77-ac1d-47f089051ba1#06a20f89-b335-435f-b5e4-2657eeb076ff" />
    <author>
      <name>blank</name>
    </author>
    <id>http://CPP.tribe.net/thread/3eee7f5d-a883-4b77-ac1d-47f089051ba1#06a20f89-b335-435f-b5e4-2657eeb076ff</id>
    <updated>2004-07-23T00:44:15Z</updated>
    <published>2004-07-23T00:44:15Z</published>
    <summary type="html">hullo folks, first post on these boards. I'm learning c++ currently, and am working on an assignment with recursion.&#xD;
&#xD;
the assignment is to write a recursive function named reverseWithinBounds, that has an argument that is an array of characters and two arguments that are bounds on array indices. the function has to reverse the order of those entries in the array whose indices are between the two bounds. so for example, if the array is&#xD;
a[0] == 'A' a[1] == 'B' a[2] == 'C' a[3] == 'D' a[4] == 'E'&#xD;
&#xD;
and the bounds are 1 and 4, then after the function is run the array elements should be:&#xD;
&#xD;
a[0] == 'A' a[1] == 'E' a[2] == 'D' a[3] == 'C' a[4] == 'B'&#xD;
&#xD;
i wrote mine so that the user can enter his own word and bounds, i opted to set it up for use with the word 'partytime'. here's my code - &#xD;
&#xD;
#include&amp;amp;lt;iostream&gt;&#xD;
&#xD;
using namespace std;&#xD;
&#xD;
void reverseWithinBounds( char x[], const int bound1, const int bound2 );&#xD;
&#xD;
&#xD;
int main()&#xD;
{&#xD;
    char x[10];&#xD;
    int bound1, bound2;&#xD;
    char ch;&#xD;
    &#xD;
    cout &amp;amp;lt;&amp;lt; "enter a nine letter word: " &amp;amp;lt;&amp;lt; endl;&#xD;
    for( int i = 0; i &amp;lt; 10; i++ ){&#xD;
        cin.get(ch);&#xD;
        x[i] = ch;&#xD;
    }&#xD;
    cout &amp;amp;lt;&amp;lt; "enter the first bound: " &amp;amp;lt;&amp;lt; endl;&#xD;
    cin &gt;&gt; bound1;&#xD;
    cout &amp;amp;lt;&amp;lt; "enter the second bound: " &amp;amp;lt;&amp;lt; endl;&#xD;
    cin &gt;&gt; bound2;&#xD;
&#xD;
    for( int j = 0; j &amp;lt; bound1; j++ )&#xD;
        cout &amp;amp;lt;&amp;lt; x[j];&#xD;
    reverseWithinBounds( x, bound1, bound2 );&#xD;
    &#xD;
    return 0;&#xD;
    &#xD;
 } &#xD;
    &#xD;
&#xD;
&#xD;
&#xD;
 /******************************************************************/&#xD;
 &#xD;
 void reverseWithinBounds(         char x[], &#xD;
                             const int bound1,&#xD;
                             const int bound2 )&#xD;
 {&#xD;
&#xD;
     int i = bound1;&#xD;
     if( x[i] != '\n' ){&#xD;
         reverseWithinBounds( x, bound1, bound2 );&#xD;
         cout &amp;amp;lt;&amp;lt; x[i];&#xD;
         i++;&#xD;
     }&#xD;
 }&#xD;
&#xD;
it compiles fine, it gets the information fine, but when it gets to the reverseWithinBounds function, it just shuts down. I'm sure it's something obvious causing the problem, I have a tendency to not see obvious problems ( occam and i are not friends )&#xD;
&#xD;
greatly appreciate any help</summary>
    <dc:creator>blank</dc:creator>
    <dc:date>2004-07-23T00:44:15Z</dc:date>
  </entry>
</feed>



