Topic: 请教输出以下图形的代码!!

  Print this page

1.请教输出以下图形的代码!! Copy to clipboard
Posted by: fxbianxiu
Posted on: 2005-01-13 15:19

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

输出以上图形的代码怎么编啊?

2.Re:请教输出以下图形的代码!! [Re: fxbianxiu] Copy to clipboard
Posted by: d1q2j3
Posted on: 2005-02-26 17:40

public class test{
  public static void main(String args[]){
    int x=5;
    if (x%2==0){
      System.out.println("erro");
      return;
    }
    for(int i=0;i<x;i+=2){
      for(int j=0;j<=i;j++){
        System.out.print('*');
      }
      System.out.println();
    }
    for(int i=x-2;i>0;i-=2){
      for(int j=0;j<i;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