请问用java怎么打出这个代码?

2025-01-01 16:33:53
推荐回答(1个)
回答1:

public class test {
public static void main(String args[])
{
int n,i,k,j;
for(n=1; n<=9; n++) //n在最外层控制行数
{
for(i=1; i<=9-n;i++)
System.out.print(" ");
for(k=1; k<=n; k++)
System.out.print(k);
for(j=n-1; j>=1;j--)
System.out.print(j);
System.out.print("\n");
}
}
}