数字斜塔
根据输入屏幕上输出如下图所示的数字斜塔
package hello; import java.util.Scanner; public class Hello { public static void main(String[] args) { int i,k; Scanner in = new Scanner(System.in); int m= in.nextInt(); int a[][]=new int [m+1][m+1]; a[1][1]=1; for(k=1;k<=m;k++){ a[k][1]=a[1][k-1]+1; System.out.print(a[k][1]+" "); for(i=2;i<=m-k+1;i++){ a[k][i]=a[k][i-1]+i-1+k; System.out.print(a[k][i]+" "); } System.out.println(""); } } }