Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1757063
  • 博文数量: 293
  • 博客积分: 10574
  • 博客等级: 上将
  • 技术积分: 5085
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-22 17:00
文章分类

全部博文(293)

文章存档

2011年(27)

2010年(84)

2009年(62)

2008年(120)

我的朋友

分类:

2009-08-10 16:46:11

直角三角形 awk -f 'as1'
cat as1
BEGIN {
        i=1;
        while(i<=10) {
                j=1;
                while(j<=i) {
                        printf "x";
                        j++;
                }
                printf "\n";
                i++;
        }
}

直角空心三角形 awk -f 'as2'
cat as2
BEGIN {
        i=1;
        while(i<=10) {
                j=1;
                while(j<=i) {
                        if (j==1 || j==i || i==10)
                                printf "x";
                        else
                                printf " "
                        j++;
                }
                printf "\n";
                i++;
        }
}

等腰三角形 awk -f 'as3'
cat as3
BEGIN {
        i=1;
        while(i<=10) {
                j=1;
                while(j<=(10-i)) {
                        printf " ";
                        j++;
                }
                j=1;
                while(j<=(2*i-1)) {
                        printf "x";
                        j++;
                }
                printf "\n";
                i++;
        }
}

等腰空心三角形 awk -f 'as4'
cat as4
BEGIN {
        i=1;
        while(i<=10) {
                j=1;
                while(j<=(10-i)) {
                        printf " ";
                        j++;
                }
                j=1;
                while(j<=(2*i-1)) {
                        if (j==1 || j==(2*i-1) || i==10 )
                                printf "x";
                        else
                                printf " "
                        j++;
                }
                printf "\n";
                i++;
        }
}
阅读(1417) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~