Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Nested For Loop [EXAMPLES!]

Name: ALPHA 2011-07-05 13:38

Hi,
Here is a collection of few examples for NESTED FOR LOOP.
Simple codes in how to use nested loops,
There is only the code, no explanation (not good at explaining anything)
So, just try to understand the program
Hope this will help as much people as possible
Let's Stop talking and just begin

OK
Here we go!

1.Get the following output :
a.
1
12
123
1234
12345
123456
1234567
12345678
123456789

//Numbers Ladder
//Nested Loops
//By ALPHA
//On 22 Oct 2008
//www.CodeCall.net
//----------------------
public class testFor
{
    public static void main(String [] args)
    {
        for (int i=1; i<=9; i++)
        {
            System.out.println();
            for (int j=1; j<=i; j++)
            {
                System.out.print(j);
            }
        }
      System.out.println();
    }
}

Name: Anonymous 2011-07-07 17:51

print '\n'.join(''.join(map(str, xrange(1, i+1))) for i in xrange(1,10))

Ironic how the FIOC version has no indentation. Problem Lispfags?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List