-7

So I need to display the following pattern

0 1 2
1 1 2
2 2 4

1 2 3
2 4 6
3 6 9

2 3 4
3 9 12
4 12 16

so far this my code..

            int a,b,c,z;
    for(a=0;a<3;a++)
    {
        System.out.print("\n");
        for(b=0;b<3;b++)
        {

            for(c=0;c<3;c++)
            {
                z=((c+b)+(a));
                System.out.print(z);
                System.out.print("\t");
            }
            System.out.print("\n");
        }
    }

output:

0 1 2
1 2 3
2 3 4

1 2 3
2 3 4
3 4 5

2 3 4
3 4 5
4 5 6

4

1 回答 1

3

The pattern is like a multiplication table. Use a multiplication not an addition

于 2013-10-10T13:11:44.677 回答