recursive function

Can someone show how to do recursive function by hand not complier.

thank
Length of list is:
    0 if the list is empty
    1 (for the first element in the list) + Length of remainder of list

So length of () is 0

Length if (hello) =
1 + length of () =
1 + 0 =
1

Length of (hello friend, come with us) =
1 + length of (friend, come with us) =
1 + 1 + length of (come with us) =
1 + 1 + 1 + length of (with us) =
1 + 1 + 1 + 1 + (us) =
1 + 1 + 1 + 1 + 1 + length of () =
1 + 1 + 1 + 1 + 1 + 0 =
5

Hope this helps.
I still don't understand
about this

1
2
3
4
5
6
7
8
void Example (int Z)
{
         if (z!=0)
         {
             Example (z/2);
             cout << K%2;
         }
}
Cleaned up the example:

1
2
3
4
5
6
7
8
void DisplayInBinary( unsigned Z )
{
    if (Z != 0)
    {
        Example( Z / 2 );
        cout << (Z % 2);
    }
}


Oh, wait... same person?

Ever read, "wash, rinse, repeat" on your shampoo bottle? How many times are you supposed to repeat? (Until your hair is clean.)

Grab a handful of chocolates. How many do you have?
Eat one. That's one chocolate (hah hah hah hah).

How many chocolates did you have? One plus the number of chocolates in your hand.

Just keep going until you have an empty hand.


You need to think about this a bit to wrap your brain around it. Don't give up.
I got it now
lol. One question about String,

when it say s2.replace (3,2 s1);

i know that 3 is move 3 place and what 2?
Last edited on
Topic archived. No new replies allowed.