public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n=scanner.nextInt(); for(int i =n;-i<=n;i=i-2){ int z=i; if(i<0){ if(z==-1){ continue; } z=-i; } for(int j =0;j<(n-z)/2;j++){ System.out.print(" "); } for(int j =0;j<z;j++){ System.out.print("*"); } System.out.println(); } }
java 输入奇数 打印沙漏
最新推荐文章于 2023-01-30 15:33:28 发布