美文网首页前后端之路程序员
如何用java在命令行打出心

如何用java在命令行打出心

作者: 吃盖浇饭 | 来源:发表于2018-06-16 08:40 被阅读5次
    image.png
    
    System.out.println("1.第四题");        
            int x = 9;
            for (int i = 1; i <= x; i++) {
                for (int j = 1; j <= x - i; j++) {
                
                    System.out.print(" ");      
                                                        
                }
                for (int k = 1; k <= 2 * i - 1; k++) {
                    int num = 2 * i - 1;
                    if(i < ((x / 2) + 2)) {                 
                        continue;
                        
                    }else if(k>( num / 2 -(9 - i)) && k<(num / 2 + (11 - i))){
                        System.out.print(" ");
                        continue;
                    }
                    System.out.print("*");
                }
                if(i>4){
                    System.out.println();
                }   
                Thread.sleep(100);
            }
            for (int i = 1; i < x; i++) {
                for (int j = 1; j <= i; j++) {
                    System.out.print(" ");
                }
                for (int k = 1; k <= 2 * (x - i)  - 1; k++) {
                    System.out.print("*");
                }
                System.out.println();
                Thread.sleep(100);
            }
    

    相关文章

      网友评论

        本文标题:如何用java在命令行打出心

        本文链接:https://www.haomeiwen.com/subject/ujwveftx.html