have to make 4 triangles

*
**
***
****

****
***
**
*

up to 10 lines on each, but to save space i threw down 4, i have those done no problem here is the code i popped to make those happen, this is VB '05 Command App btw.

Sub Main()
        Dim Rcounter As Integer = 1 (Rcounter=Rowcounter)
        Dim Ccounter As Integer = 1 (Ccounter...ya=ColumnCounter)
        Dim Space As Integer = 1 [(not sure if this should be "1" or "nothing", then again im not sure it matters) but this is referring to my question not the above triangles.]


        For Rcounter = 1 To 10
            For Ccounter = 1 To Rcounter
                Console.Write("*")
            Next
            Console.WriteLine()
        Next
        Console.WriteLine()
        For Rcounter = 1 To 10
            For Ccounter = Rcounter To 10
                Console.Write("*")
            Next
            Console.WriteLine()
        Next
        Console.WriteLine()

Easy and simple ya, ok my "Problem" is the next two,
think of these as full squares not triangles


___*
__**
_***
****

****
_***
__**
___*

Oh like above there are ten rows/columns, the difference if you havent already seen is the SPACES... ugly word... hate it.. evil :twisted:
anyway, need some help on how to do that, also as seen in the above code, i have to use For...Next loops. The problem i was having was being able to make the spaces happen all at once, and, happen before the *'s. If anyone is able to help, besides the fact that your my new hero for the day... ill have to /hug you or something.

Aye, you mean something, (at least i hope), like this

For Rcounter = 1 To 10
            For Ccounter = 1 To Rcounter
                Console.Write("*")
                For Space = "PART IM CONFUSED ON :)"
                    Console.Write(" ")

                Next
                "MAYBE SOMETHING HERE IDK"




            Next
            Console.WriteLine()
        Next
        Console.WriteLine()

Maybe i should have just connected this to the above code, but this is the last part, it matters because 'space' is defined above, which also is my problem with what to define it as, "1" or "nothing", either way i think the same will come out.

yes thats better.

I have a similar thing that makes union jacks (flags) but its in VB6, ill see if i can find it

The first triangle... the one that is
_________*
________**
_______***
______****
_____*****
____******
___*******
__********
_*********
**********
Since it needs 9 spaces I was thinking the code would need to be something like,

For Space = 10 To RCounter Step -1

, but it is placing the spaces AFTER the *, so its looking like this:
*_________ 9 spaces after each
*________*________ 8 spaces after each
*_______*_______* 7 spaces after each
*______*______*______* etc, etc
*_____*_____*_____*_____*
*____*____*____*____*____*
*___*___*___*___*___*___*
*__*__*__*__*__*__*__*
*_*_*_*_*_*_*_*_*
**********

Though that looks cool, its wrong... and i tweaked it in everyway i could think of, like

For Space = 10 To Ccounter Step -1

, tried it w/o the

Step -1

etc etc, nothing.

Ok apparently im on the retarded bus or something this week, problem is figured out... here it is just in case someone cares..

For Rcounter = 1 To 10
            For Space = Rcounter To 2 Step -1
                Console.Write(" ")
            Next
            For Ccounter = 10 To Rcounter Step -1
                Console.Write("*")
            Next
            Console.WriteLine()
        Next
        Console.WriteLine()
        For Rcounter = 1 To 10 
            For Space = Rcounter To 9
                Console.Write(" ")
            Next
            For Ccounter = Rcounter To 1 Step -1
                Console.Write("*")
            Next
            Console.WriteLine()
        Next

Those solve both triangles, not just the first one. Thanks for the replies bennett, though they were probably just for post +'s :lol:.

This article has been dead for over six months. Start a new discussion instead.