Topic: 怎么才可以打印出来一个菱形?? |
Print this page |
1.怎么才可以打印出来一个菱形?? | Copy to clipboard |
Posted by: Tyrone_1983 Posted on: 2005-05-12 13:03 用*做标记就可以!谢谢各位!!!!!!! |
2.Re:怎么才可以打印出来一个菱形?? [Re: Tyrone_1983] | Copy to clipboard |
Posted by: zhuzi0474 Posted on: 2005-05-12 17:19 就是基本的输入输出他 输出几行 按照你要画的图形边框的地方用*,其他地方输出空各 |
3.Re:怎么才可以打印出来一个菱形?? [Re: Tyrone_1983] | Copy to clipboard |
Posted by: gao627 Posted on: 2005-05-12 22:05 public class ling { public static void main(String[] args) { System.out.println("开始打印菱形:\n"); int i=1,j=1,k=0; int iMax=11;//最大一行等于9 //第一行等于1 需要补空格数等于 iMax-1/2 for(;i<=iMax;i=i+2) { System.out.print(" "); for(j=1;j<=((iMax-1)/2-k);j++) System.out.print(" "); for(j=1;j<=i;j++) System.out.print("*"); System.out.println("\n"); k++; } i=iMax-2; k=0; for(;i>0;i=i-2) { System.out.print(" "); k++; for(j=1;j<=k;j++) System.out.print(" "); for(j=0;j<i;j++) System.out.print("*"); System.out.println("\n"); } System.out.println("\n菱形输出完毕。"); } } |
4.Re:怎么才可以打印出来一个菱形?? [Re: Tyrone_1983] | Copy to clipboard |
Posted by: 2352439 Posted on: 2005-05-23 00:09 class Lesson { public static void main(String[] args) { drawRhombus(4,7); } static void drawRhombus(int x,int y) { for(int i=0;i<x;i++) { for(int j=0;j<x-(i+1);j++) { System.out.print(" "); } for(int j=0;j<i*2+1;j++) { System.out.print('*'); } System.out.println(); } for(int i=0;i<x-1;i++) { for(int j=0;j<i+1;j++) { System.out.print(" "); } for(int j=0;j<y-(i+1)*2;j++) { System.out.print('*'); } System.out.println(); } } } |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |