码迷,mamicode.com
首页 > 系统相关 > 详细

《新手上路》老师让我们用eclipse画图形,然后我蒙圈了

时间:2016-08-14 23:50:19      阅读:491      评论:0      收藏:0      [点我收藏+]

标签:

  这两天我们刚学到程序流程控制,把FOR循环讲完给我们弄了几道趣味题:

    

利用双重循环打印 *堆成的三角形

然后思索3个钟头后得出结果:

package jwork;

public class text6 {

 public static void main(String[] args) {  

   for(int x=1;x<=5;x++){            

     for(int y=x;y<=4;y++){   

    System.out.print(" ");

    }       

     for(int y=x;y>=1;y--){   

     System.out.print("*");  

     }      

     for(int y=x-1;y>=1;y--){   

     System.out.print("*");   }   

     if(x>=3){   

     System.out.print("*");  

     }  

     System.out.println(" ");  

     }       

   }

}

    怎么都感觉太多了,太长了,新手莫非只能这样了??!!

《新手上路》老师让我们用eclipse画图形,然后我蒙圈了

标签:

原文地址:http://www.cnblogs.com/buoubuhuiku/p/5771347.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!