Help With Triangle Program!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bigstevizzle
    New Member
    • Apr 2007
    • 2

    #1

    Help With Triangle Program!!!

    I need help starting out this program, ANY HELP IS GREATLY APPRECIATED. I have to make a code up that a user inputs a number and the program makes lines with an asterisks. The first line will have one asterisk and the next line will have two and so on until it gets to the number entered making a triangular shape of asterisks. Thanks in advance for any help!

    It should come out like this if the user inputed number was for example 7
    *
    **
    ***
    ****
    *****
    ******
    *******
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

    Please read the Posting Guidelines and particularly the Coursework Posting Guidlines.

    Then when you are ready post a new question in this thread.

    MODERATOR

    Comment

    • bigstevizzle
      New Member
      • Apr 2007
      • 2

      #3
      I tried making this code but i need help getting it complete...some thing like this

      Code:
      Dim i As Integer
      Dim n As Integer
      Dim j As Integer
      Dim lstDisplay As Integer
      i = 0
      i = 0
      While i < n
          j = 0
          j = 0
          While j <= i
              lstDisplay = ("*")
              System.Math.Min(System.Threading.Interlocked.Increment(j), j - 1)
          End While
          lstDisplay = ("" & Microsoft.VisualBasic.Chr(10) & "")
          System.Math.Min(System.Threading.Interlocked.Increment(i), i - 1)
      End While
      Last edited by Killer42; Apr 24 '07, 03:37 AM. Reason: Added [CODE] tag.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        System.Math.Min (System.Threadi ng.Interlocked. Increment(j), j - 1)
        What the BLEEP does this do? (Don't worry about the space in "incre ment" - it's just some formatting thing that TheScripts is doing to the text).

        Phew! Interesting code. A couple of questions...
        • Have you tried using a For loop rather than a While loop? They're much simpler.
        • Have you worked with strings at all? Probably the simplest thing to do would be to start with an empty string each time 'round, and add asterisks onto it until you reach i.

        Comment

        • Tig201
          New Member
          • Mar 2007
          • 103

          #5
          if you are using VB6 you could use "String$(N, C)" it will create a string of C N times (ie String$(10,"*") would return "********** ") if you use a for loop as Killer42 suggested then you could use the counter to supply the number argument.

          Comment

          Working...