CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2010
    Posts
    4

    Please help with this method!

    Write a public static method named starPrinter that will take an int as a parameter and
    print lines of stars as shown below.

    The header of the method will be public static void starPrinter(int n) .

    e.g.
    If the value of n is 5, then the method should print
    *
    ***
    *****
    *******
    *********

    If the value of n is 3, then the method should print
    *
    ***
    *****

    Please help!

  2. #2
    Join Date
    May 2010
    Posts
    4

    Re: Please help with this method!

    It actually has to look like pyramid as opposed to evenly stacked

    " *
    " ***
    " *****

  3. #3
    Join Date
    May 2010
    Posts
    4

    Re: Please help with this method!

    A picture of how it is supposed to look is attached below
    Attached Images Attached Images

  4. #4
    Join Date
    May 2010
    Posts
    4

    Re: Please help with this method!


  5. #5
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Please help with this method!

    So what part of that is giving you trouble? We aren't going to write the code for you.

    If you're having trouble with the algorithm, consider how you would write out the pattern by hand, character by character, line by line, using spaces and stars. Think about how the number of spaces and stars changes from line to line.

    Technical skill is mastery of complexity, while creativity is mastery of simplicity...
    E. C. Zeeman
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured