要输出
1
1 2 1
1 2 3 2 1 
1 2 3 4 3 2 1 thanks

解决方案 »

  1.   


    import java.util.Scanner;public class Test12 { public static void main(String[] args) {
    System.out.println("请输入一个1~15之间的整数:");
    Scanner scanner = new Scanner(System.in);

    int n = scanner.nextInt();
    for(int i =1; i<=n; i++){
    for(int j = 0; j<2*i-1; j++){
    if(i-j>0){
    System.out.print(j+1 + "  ");
    }else{
    System.out.print(2*i-j-1 + "  ");
    }

    }
    System.out.println();
    }

    }
    }
      

  2.   


    for(int i=0;i<4;i++){
    for(int j=0;j<2*i+1;j++){
    if(i >= j){
    System.out.print(j+1+" ");
    }else{
    System.out.print(2*i-j+1+" ");
    }
    }
    System.out.println();
    }
    为了简单直接用你那些数据写的,如果要扩展改改相关数据即可。