2005/03/27 | 菱形输出
类别(编程相关) | 评论(0) | 阅读(60) | 发表于 00:01
//菱形输出
public class diamondShow
{
    public static void main(String a[])
    {
        String s="*";
        int i=0;
        int j=0;
        int k=1;
        for(i=j;i<6;i++)
        {
            for(j=i;j<6;j=j+2)
            {
                System.out.print(" ");
            }            
            for(k=0;k<i+1;k=k+1)
            {
                System.out.print("*");
            }
            i=i+1;
            System.out.print("\n");
        }
        i=j=k=0;
        for(i=j;i<7;i++)
        {
            for(j=1;j<i;j=j+2)
            {
                System.out.print(" ");
            }            
            for(k=i;k<7;k=k+1)
            {
                System.out.print("*");
            }            
            System.out.print("\n");
            i=i+1;
        }        
    }
}
0

评论Comments