C 语言 等腰三角形

来源:百度知道 编辑:UC知道 时间:2024/05/12 05:30:21
*
* *
* * *
* * * *
* * * * *
是等腰三角形哦
还有倒过来的 :
* * * * *
* * * *
* * *
* *
*

已经编写过了!!
去我的baidu个人博客找吧!!

#include <stdio.h>

void Print(int n)
{
for ( int i = 0; i < n; ++i )
printf("*");
printf("\n");
}

void PrintAngi(int n, int flag)
{
int i;
if ( flag )
for ( i = 0; i <= n; ++i )
Print(i);
else
for ( i = n; i >0; --i )
Print(i);
}

void main()
{
PrintAngi(10,1);
PrintAngi(10,0);
}

include "stdio.h"
void main()
{
int i,j;
for(i=1,i<=5;i++)
for(j=1,j<=i;j++)
printf ("%s","*");
}

反过来的直接改为for(j=1,j<=6-i;j++)