如题,怎样只用两行代码就能够打印出菱形

解决方案 »

  1.   

    光类声明和 main 方法就两行
      

  2.   

    Class{main(){System.out.println("菱形")}}
    只要一行代码··虽然不规范··
      

  3.   

    也没说一行写多少语句,可以这样
    ……;……;……;……;……;……;……:
    ……;……;System.out.print(‘*’);……;……;………………
    一共两行
      

  4.   

    这题目真无聊...
    我也有够无聊的... for(int row = 1,col = 7; row <= 5; row ++) 
    System.out.println((row<=col/2)?(String.format("%"+(col - (row*2-1))/2+"s"," ") + String.format("%0"+(row*2-1)+"d",0) + String.format("%"+(col - (row*2-1))/2+"s"," ")):(String.format("%"+(col - ((col-1-row)*2-1))/2+"s"," ") + String.format("%0"+((col-1-row)*2-1)+"d",0) + String.format("%"+(col - ((col-1-row)*2-1))/2+"s"," ")));

      

  5.   

    加上函数 public static void main(String[] args) {
    test(5);
    test(6);
    }

    public static void test(int i) {
    for(int row = 1,col = (i%2)==0?i+3:i+2; row <= i; row ++) 
    System.out.println((row<=col/2)?(String.format("%"+(col - (row*2-1))/2+"s"," ") + String.format("%0"+(row*2-1)+"d",0) + String.format("%"+(col - (row*2-1))/2+"s"," ")):(String.format("%"+(col - ((col-1-row)*2-1))/2+"s"," ") + String.format("%0"+((col-1-row)*2-1)+"d",0) + String.format("%"+(col - ((col-1-row)*2-1))/2+"s"," ")));

    }
      

  6.   


    System.out
           .print("◇");