黑马程序员技术交流社区

标题: 无聊打个”空心菱形“,净拿java作图了~~~ [打印本页]

作者: HwH199209    时间: 2015-8-10 22:05
标题: 无聊打个”空心菱形“,净拿java作图了~~~
Compiling ForForTest.java......
------Output------
                                        *
                                *                *
                        *                                *
                *                                                *
        *                                                                *
*                                                                                *
        *                                                                *
                *                                                *
                        *                                *
                                *                *
                                        *
[Finished in 1.3s]

class ForForTest{
        public static void main (String[] args){
                for(int x=0;x<5;x++){
                        for(int y=x;y<5;y++){
                                System.out.print("\t");
                        }
                        // if(x==0){
                        //         System.out.print("*");
                        // }
                        // else
                                System.out.print("*");       
                        for(int y=0;y<x;y++){
                                System.out.print("\t\t");
                        }
                        if(x==0){
                                 System.out.println();
                        }
                        else
                                System.out.println("*");
                       
                }
                for(int x=0;x<=5;x++){
                        for(int y=0;y<x;y++){
                                System.out.print("\t");
                        }
                        if(x!=5)
                        System.out.print("*");
                        for(int y=x;y<5;y++){
                                System.out.print("\t\t");
                        }
                        // if(x==0){
                        //          System.out.println("*");
                        // }
                        // else
                                System.out.println("*");
                }
        }
}
作者: HwH199209    时间: 2015-8-10 22:06
图像有点扭曲了。。。。。应该是躺着的菱形




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2