Java循环练习:打印图案-4

时间:2016-04-30 18:22:05   收藏:0   阅读:269
package practiceGO;
/**
 * *****
 * *   *
 * *   *
 * *   *
 * ***** 
 */
public class Cto {

	public static void main(String[] args) {
		for(int i=0; i<5; i++){
			for(int j=0; j<5; j++){
				if (i==0 || i==4) {
					System.out.print("*");
				}else {
					if (j==0 || j==4) {
						System.out.print("*");
					}else{
						System.out.print(" ");
					}
				}
			}
			System.out.println();
		}
	}
}

运行结果:

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


原文:http://11317783.blog.51cto.com/11307783/1769216

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!