zoukankan      html  css  js  c++  java
  • 打印沙漏

    public class sdf {
        public static void main(String[] args) {
            int n = 7;
            int i,j,k,m,p;
            k = n/2+1;
            for (i = 0; i <= n; i++) {
                m = k - Math.abs(i-k);
                 p = Math.abs(2*(k-i))-1;
                if(p == -1){
                    continue;
                }
                for(j = 0 ; j < m; j ++){
                    System.out.print(" ");
                }
                for(j = 0; j < p; j++){
                    System.out.print("*");
                }
                System.out.println();
            }
        }
    }

  • 相关阅读:
    How Many Answers Are Wrong
    Agri-Net —poj1258
    食物链
    A Bug's Life
    畅通工程
    Shortest path of the king
    Alex and Number
    KMP
    快速幂
    0x04
  • 原文地址:https://www.cnblogs.com/superws/p/5256673.html
Copyright © 2011-2022 走看看