初学者简单的小程序

      J2SE开发 2008-1-30 11:37
/**
 *       输出:
 *                          *
 *                         * *
 *                        *   *
 *                       *     *
 *                      *       *
 *                       *     *
 *                        *   *
 *                         * *
 *                          *
 */
public class exercise4_6_4
{
 public static void main(String[] args)
 {
  for(int a=4,b=1;a+b<=9;a--,b+=2)
  {
   for(int c=1;c<=a;c++)
     System.out.print(" ");
   for(int d=1;d<=b;d++)
   {
    if(d==1||d==b)
      System.out.print("*");
    else
      System.out.print(" ");
   }
   System.out.println();
  }
  for(int a=1,b=7;a+b>=5;a++,b-=2)
  {
   for(int c=1;c<=a;c++)
    System.out.print(" ");
   for(int d=1;d<=b;d++)
   {
      if(d==1||d==b)
       System.out.print("*");
     else
       System.out.print(" ");
    }
   System.out.println();
  }
 }
}
标签集:TAGS:java
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}