0

Can I print this with triangle shape in Java?

I tried to print this with only border "1"s:

int[][] matrix = new int[5][5];


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

    matrix[i][i] = 1;
    matrix[i][0] = 1;

}
2
  • You're missing code, please share all you have, the current output and the expected output edit your post for that Commented Dec 31, 2022 at 11:25
  • 1
    "Can I print this with triangle shape in Java?" - Yes. --- On a sidenote: It's called Pascal's triangle, named after Blaise Pascal (en.wikipedia.org). Commented Dec 31, 2022 at 11:25

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.