Results 1 to 3 of 3
  1. #1
    5myl is offline Member
    Join Date
    Aug 2011
    Posts
    9
    Rep Power
    0

    Post Simple triangle printer (kinda)

    So for my computer class, my instructor gave me a challenge problem since i was doe with the rest of the work, its the beginning of the year so its kind of simple... but i can't wrap my mind around it. the problem is To create a program that prints out a triangle based on 'n'... for example:

    if n = 3,

    it would print out:

    ___*
    __**
    _***

    (the underscore would be the spaces since it won't show up)
    anyways, i know it would have to do something with a for loop, but i don't know how to account for the spaces before the stars.

    If somebody could tell me a way to go about it or how to figure it out, i would greatly appreciate it.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    You need to grab a pen and some paper. Draw various n sized triangles and count how many spaces appear before each *. If you do this enough you should see a pattern emerging. Given n then you can calculate what the initial number of spaces will be.

  3. #3
    5myl is offline Member
    Join Date
    Aug 2011
    Posts
    9
    Rep Power
    0

    Default

    Thanks, after reading your post i thought of something else completely and suddenly i figured it out... :)
    but the counting of spaces helped as well

Similar Threads

  1. Replies: 2
    Last Post: 02-20-2009, 07:25 AM
  2. printing simple text as text on printer
    By Nicholas Jordan in forum Advanced Java
    Replies: 0
    Last Post: 12-01-2008, 01:42 AM
  3. Specifying a Network Printer in Printer Servlet
    By shapez in forum New To Java
    Replies: 0
    Last Post: 03-06-2008, 03:21 PM
  4. need help, weird question kinda.
    By carlos123 in forum New To Java
    Replies: 6
    Last Post: 01-22-2008, 03:19 AM
  5. Replies: 0
    Last Post: 08-09-2007, 06:30 AM

Posting Permissions

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