请求帮助!关于打印数字图形的问题!!
请求帮助!关于打印数字图形的问题!!1 3 6 10 15
2 5 9 14
4 8 13
7 12
11
程序代码:public class Print {
public void test(int n) {
int y = 0;
int y1 = 0;
for (int i = 0; i < n; i++) {
int x1 = 0;
int x = 1;
y = y + y1;
y1++;
x = x + y;
for (int j = 2; j < n - i + 2; j++) {
x = x + x1;
x1 = j + i;
System.out.print(x + "\t");
}
System.out.println();
}
}
public static void main(String[] args) {
new Print().test(5);
}
}没有加注释,应该不难明白,y,y1用来控制行的起点,x,x1用来控制每行数字的递增,