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

全部博文(293)

文章存档

2011年(27)

2010年(84)

2009年(62)

2008年(120)

我的朋友

分类: C/C++

2009-08-12 00:57:50

直角三角形 t1.c 
#include
main() {
        int i,j;
        i=1;
        while (i<=10) {
                j=1;
                while (j<=i) {
                        printf("*");
                        j++;
                }
                printf("\n");
                i++;
        }
}

直角空心三角形 t2.c
#include
main() {
        int i,j;
        i=1;
        while (i<=10) {
                j=1;
                while (j<=i) {
                        if (j==1 || j==i || i==10)
                                printf("*");
                        else
                                printf(" ");
                        j++;
                }
                printf("\n");
                i++;
        }
}
等腰三角形 t3.c
#include
main() {
        int i,j;
        i=1;
        while (i<=10) {
                j=1;
                while (j<=10-i) {
                        printf(" ");
                        j++;
                }
                j=1;
                while (j<=(2*i-1)) {
                        printf("*");
                        j++;
                }
                printf("\n");
                i++;
        }
}
等腰空心三角形 t4.c
#include
main() {
        int i,j;
        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("*");
                        else
                                printf(" ");
                        j++;
                }
                printf("\n");
                i++;
        }
}
阅读(1805) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~