当前位置:网站首页>[C language practice - printing hollow upper triangle and its deformation]
[C language practice - printing hollow upper triangle and its deformation]
2022-06-26 15:27:00 【Beginners of C language】
Active address : Graduation season · The technique of attack er
It's hot in summer , We welcome the graduation season in the heat wave , This is farewell , It is also the beginning of a new starting point . This is the month of graduation , Every year I see many graduates leave school to work , Students prepare for exams and summer internships , Very emotional , No matter what , As a student in school , While playing well , Still want to be able to learn in a down-to-earth way , Lay a solid foundation , From the beginning C Beginning of language , Prepare for the follow-up internship .
List of articles
Preface
The front is already in 【C Language practice —— Print the upper triangle and its deformation 】 、【C Language practice —— Print the upper triangle and its deformation ( Blank version )】 、【C Language practice —— Print the hollow lower triangle and its deformation 】 Practiced printing upper triangle and its deformation 、 Print the hollow triangle and its deformation .
On this basis , Practice printing hollow upper triangles and their deformations , As shown in the figure below : They are the blank free versions of the upper triangle 、 Blank version 、 Hollow version

1、 Print white top triangle
1.1 Hollow upper triangle left aligned version
// Print white top triangle ——— Left aligned version
int main()
{
int n = 0;
while (scanf("%d", &n) != EOF)
{
for (int i = 0; i < n; i++)
{
int j = 0;
for (j = 0; j < n - i; j++)
{
// Output when conditions are met * , That is, on the boundary is *
if (i == 0 || j == 0 || j == n - i - 1 )
printf("* ");
else
printf(" ");// All points not on the boundary are spaces
}
printf("\n");
}
}
return 0;
}
The results are as follows :

1.2 Hollow upper triangle middle aligned version
// Print white top triangle ——— Middle aligned version
int main()
{
int n = 0;
while (scanf("%d", &n) != EOF)
{
for (int i = 0; i < n; i++)
{
int j = 0;
for (j = 0; j <= i; j++)
{
printf(" ");
}
for (j = 0; j < n - i; j++)
{
// Output when conditions are met * , That is, on the boundary is *
if (i == 0 || j == 0 || j == n - i - 1 )
printf("* ");
else
printf(" ");// All points not on the boundary are spaces
}
printf("\n");
}
}
return 0;
}
The results are as follows :

1.3 White upper triangle right aligned version
// Print white top triangle ——— Right aligned version
int main()
{
int n = 0;
while (scanf("%d", &n) != EOF)
{
for (int i = 0; i < n; i++)
{
int j = 0;
for (j = 0; j <= 2 * i; j++)
{
printf(" ");
}
for (j = 0; j < n - i; j++)
{
// Output when conditions are met * , That is, on the boundary is *
if (i == 0 || j == 0 || j == n - i - 1)
printf("* ");
else
printf(" ");// All points not on the boundary are spaces
}
printf("\n");
}
}
return 0;
}
The results are as follows :

summary
In this paper, we practice printing the deformation of the upper triangle of the hollow , Mainly practice :
- Outer loop 、 Application of internal circulation
- Pay attention to the number of lines 、 Space number 、 Symbol * Mathematical expressions between numbers
Active address : Graduation season · The technique of attack er
边栏推荐
- Restcloud ETL resolves shell script parameterization
- Pod scheduling of kubernetes
- 北京房山区专精特新小巨人企业认定条件,补贴50万
- 夏令营来啦!!!冲冲冲
- Applet: uniapp solves vendor JS is too large
- The tablestack function of the epidisplay package of R language makes a statistical summary table (descriptive statistics of groups, hypothesis test, etc.), does not set the by parameter to calculate
- RestCloud ETL与Kettle对比分析
- BLE抓包调试信息分析
- RestCloud ETL抽取動態庫錶數據實踐
- Is it safe to buy stocks and open accounts through the QR code of the securities manager? Want to open an account for stock trading
猜你喜欢
![[tcapulusdb knowledge base] Introduction to tcapulusdb general documents](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[tcapulusdb knowledge base] Introduction to tcapulusdb general documents

【ceph】mkdir|mksnap流程源码分析|锁状态切换实例

10 minutes to understand bim+gis fusion, common BIM data formats and characteristics

在校生学习生涯总结(2022)

【小程序实战系列】小程序框架 页面注册 生命周期 介绍

Unable to download Plug-in after idea local agent

sqlite加载csv文件,并做数据分析

RestCloud ETL与Kettle对比分析
![[wechat applet] event binding, do you understand?](/img/83/6242e972538d0423fd4155140bb521.png)
[wechat applet] event binding, do you understand?

使用卷积对数据进行平滑处理
随机推荐
Restcloud ETL resolves shell script parameterization
Particle filter PF -- Application in maneuvering target tracking (particle filter vs extended Kalman filter)
Analysis of ble packet capturing debugging information
JS之手写 bind、apply、call
使用卷积对数据进行平滑处理
编译配置in文件
【TcaplusDB知识库】TcaplusDB单据受理-事务执行介绍
[tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction
One click analysis hardware /io/ national network performance script (strong push)
vsomeip3 双机通信文件配置
Evaluate:huggingface detailed introduction to the evaluation index module
评价——模糊综合评价
PHP file upload 00 truncation
【ceph】cephfs的锁 笔记
TCP/IP协议竟然有这么多漏洞?
Optimizing for vectorization
Lexin AWS IOT expresslink module achieves universal availability
clustermeet
Don't remove custom line breaks on reformat
【C语言练习——打印空心上三角及其变形】