打印等边三角形和直角三角形(用循环)C语言

程序:

#include"stdio.h"

int main(){

int k1,k2;

for(k1=1;k1<=4;k1++){

for(k2=1;k2<=4-k1;k2++)

putchar(' ');

for(k2=1;k2<=k1*2-1;k2++)

putchar('*');

putchar('\n');}

return 0;

}

运行结果:

*

***

*****

*******

程序:

#include<stdio.h>

int main()

{

int i,j;

for(i=1;i<6;i++){

for(j=1;j<6-i;j++)

{printf(" ");}

for(j=0;j<2*i-1;j++)

{printf("*");}

printf("\n");}

return 0;

}

运行结果:

*

***

*****

*******

*********

程序:

#include<stdio.h>

int main(){

int i,j;

for(i=1;i<6;i++){

for(j=1;j<6-i;j++)

printf("*");

printf("\n");}

return 0;

}

运行结果:

****

***

**

*

程序:

#include<stdio.h>

int main()

{

int i,j;

for(i=1;i<6;i++){

for(j=1;j<i+1;j++)

printf("*");

printf("\n");}

return 0;

}

运行结果:

*

**

***

****

*****

愿我们都能成为我们想要去成为的人!

最漆黑的那段路,终究要自己走完!

天道酬勤!

相关推荐
Logic1015 小时前
C语言/数据结构位运算题解:异或XOR找出学习计划中的“独特学习时间“——只出现一次的数字
c语言·数据结构·数组·位运算·时间复杂度·算法题·异或性质
wuminyu6 小时前
C++协程实现接收端的零拷贝Buffer管理原理剖析
java·linux·c语言·jvm·c++
思麟呀8 小时前
位运算:从一个整数到一个集合
c语言·数据结构·c++·算法
SuperByteMaster10 小时前
低功耗GPIO引脚配置
c语言
phltxy10 小时前
C 语言自定义类型:结构体、位段、枚举与联合体
c语言·开发语言
大侠归来12 小时前
C语言与C++在基础语法上的区别
java·c语言·c++
cu14313 小时前
细谈GM8229的具体功能与其应用
c语言·c++·人工智能·单片机
大侠归来14 小时前
C语言内存管理:从栈到堆的完整指南
c语言·开发语言·python
cu14314 小时前
细谈GM7123C的具体功能与其应用
c语言·c++·人工智能·嵌入式硬件
Logic10115 小时前
C语言/数据结构位运算题解:异或XOR找出弹子游戏机中数量为奇数的数字——只出现奇数次
c语言·数据结构·数组·位运算·时间复杂度·算法题·异或性质