2008/01/30 | 初学者简单的小程序
类别(J2SE开发) | 评论(0) | 阅读(14) | 发表于 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();
  }
 }
}
0

评论Comments