Climbing的专栏

Life is limited, but art is long

huang ClimbingID:hpdlzu80100
3116次访问,排名2万外好友4人,关注者7
热爱生活,积极向上,流自己的汗,吃自己的饭!
hpdlzu80100的文章
原创 23 篇
翻译 0 篇
转载 5 篇
评论 1 篇
最近评论
diqizhan:很喜欢这个
文章分类
收藏
    相册
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 大小可变钻石形状(Display a diamond shape constituted by asterisks)收藏

    新一篇: 摄氏温度和华氏温度的互换(Convert between Celsius and Fahrenheit temperature) | 旧一篇: 勾股数列表(Find Pythagorean Triples)

    //Display a diamond shape constituted by asterisks
    //Java how to program, 5/e, Exercises 5.20, 5.21
    import javax.swing.*;
    public class AsteriskDiamond {
    public static void main(String arg[])
    {
        
    int size;
        String Size;
        
    boolean guard;
        Size
    =JOptionPane.showInputDialog("Enter the diamond size:");
        size
    =Integer.parseInt(Size);
        
    if (size%2==0||size<1)
            JOptionPane.showMessageDialog(
    null"Please enter a nonegative odd number",
                    
    "Diamond Display",JOptionPane.ERROR_MESSAGE);
        
    else
        
    {
        
    for (int i=1;i<=size;i++)
        
    {
            
    for (int j=1;j<=size;j++)
                
    {if (i<=size/2+1)
                guard
    =(size/2+1-j<i&&size/2+1-j>=0)||(j-size/2-1<i&&j-size/2-1>=0);
                
    else
                    guard
    =(size/2+1-j<=size-i&&size/2+1-j>=0)||(j-size/2-1<=size-i&&j-size/2-1>=0);
                
    if (guard)
                    System.out.print(
    "*");
                
    else 
                    System.out.print(
    " ");}

            System.out.print(
    " ");
        }

        }

    }

    }

     

    发表于 @ 2008年04月09日 11:25:00|评论(loading...)|编辑

    新一篇: 摄氏温度和华氏温度的互换(Convert between Celsius and Fahrenheit temperature) | 旧一篇: 勾股数列表(Find Pythagorean Triples)

    评论:没有评论。

    发表评论  


    登录
    Csdn Blog version 3.1a
    Copyright © Climbing