User Profile

Collapse

Profile Sidebar

Collapse
Kahlia
Kahlia
Last Activity: Nov 9 '07, 07:05 AM
Joined: May 10 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • The current code I have (not allowing for spaces) is:

    Code:
    #include <iostream>
    
    using namespace std;
    
    void print(int n);
    
    int main()
    {
            print(4);
    
            return 0;
    }
    
    void print(int n)
    {
            if (n == 0)
            {
                    return;
            }
            else
    ...
    See more | Go to post

    Leave a comment:


  • Yeah I'd figured that.

    The problem I can see with doing it this way is that it uses iteration instead of recursion - I don't know how to implement the for loop inside a recursive function.

    I have tried implementing the loop one way and got a warning:
    warning: multi-character character constant
    and it printed:
    Code:
           10784
    1078410784
    10784
    107841078410784
     10784
    ...
    See more | Go to post

    Leave a comment:


  • Problem printing pyramid of asterisks recursively in UNIX system

    Hi. I am trying to print a pyramid of asterisks using recursion so that the recursive function takes in an integer and prints that number of lines of asterisks and then reverses, eg:

    [code="C++"]

    *
    * *
    * * *
    * * * *
    * * *
    * *
    *
    [/code]
    if you call print(4).

    I understand the general idea and have managed to put together the...
    See more | Go to post
No activity results to display
Show More
Working...