黑马程序员技术交流社区

标题: 倒等腰三角形和正等腰三角形的打印 [打印本页]

作者: 奔跑的小红帽    时间: 2015-10-15 23:45
标题: 倒等腰三角形和正等腰三角形的打印
/*
* * * * *
* * * *
  * * *
   * *
    *
*/
class Print6
{
        public static void main(String []args)
        {
                for(int x=1;x<=5;x++)
                {
                       
                        for(int y=0;y<x-1;y++)
                        {
                                System.out.print("-");
                        }
                        for(int z=0;z<=5-x;z++)
                        {
                               
                                System.out.print("* ");
                        }
                        System.out.println();
                }
        }
}

/*

    *
   * *
  * * *
* * * *
* * * * *

*/

class Print7
{
        public static void main(String []args)
        {
                for(int x=5;x>0;x--)
                {
                       
                        for(int y=x-1;y>0;y--)
                        {
                                System.out.print("-");
                        }
                        for(int z=5;z>x-1;z--)
                        {
                               
                                System.out.print("* ");
                        }
                        System.out.println();
                }
        }
}







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