求一个简单的算法,急,先谢了
输入一个参数,燃火打印出相应的维数,例:输入4 输出0000
0111
0122
0123
public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); while(n<=0){ System.out.println("n must greater than zero, please input a number again"); n = in.nextInt(); } int a[][] = new int[n][n]; for(int i = 0; i<n;i++){ for(int j=0;j<n;j++){ if(j>=i) a[i][j]=i; else a[i][j]=j; System.out.print(a[i][j]+" "); } System.out.println(); } } }