【发布时间】:2022-12-01 19:57:06
【问题描述】:
I have to make 2D array [10][10] to be filled like this: (https://i.stack.imgur.com/WCRGu.png) Please, can someone help me with this? `
int j, i;
int n=1;
for (j=9; j>=0;j--) {
for (i=11-j; i>=9-j; i++) {
if(i<10) {
a[i][j]=n;
n++;
}else{
break;
}
}
}
for (i=0;i<=9;i++) {
for(j=0;j<=9;j++) {
System.out.print(a[i][j] + " ");
}
System.out.println();
}
`
【问题讨论】:
-
What are the requirements here? Do you want to have a solution for exactly the numbers in the image or do you want a method that creates a 2D array based on some rules?
-
I want solution for exactly the numbers in the image.
标签: java arrays math multidimensional-array