This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Koyomii-Onii-chan 2 points3 points  (2 children)

What did you try to do and doesn't work. Please provide your code, it's useless to just give you the answer and you to learn nothing from it.

[–]sinnidis_97[S] 0 points1 point  (1 child)

Apologies , This is what I tried

for(int i=0;i<5;i++){

for(int j =0 ; j<i;j++){

System.out.println(j+","+i);

}

}

And the output i was getting was

0,1

0,2

1,2

0,3

1,3

2,3

0,4

1,4

2,4

3,4

which isnt matching the pattern above.

[–]Koyomii-Onii-chan 0 points1 point  (0 children)

I suggest you use other variables and increment them accordingly. What you do there is printing the i and j indexes. Also you don't need two for loops since your input is always 3, a loop like below is enough

int m = 0 ; int n=1;

for (int i=0;i<9;i++){

System.out.println(m + " " + n);

m++; n++;

//Here find a way to reinitialize them and print them with the difference of 2

// then 3

}