当前位置:网站首页>[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
边栏推荐
- Redis cluster re fragmentation and ask command
- 【TcaplusDB知识库】TcaplusDB OMS业务人员权限介绍
- 安全Json协议
- English语法_形容词/副词3级 - 原级句型
- 数据库-完整性约束
- 1. accounting basis -- several major elements of accounting (general accounting theory, accounting subjects and accounts)
- 【TcaplusDB知识库】TcaplusDB单据受理-建表审批介绍
- High frequency interview 𞓜 Flink Shuangliu join
- 使用卷积对数据进行平滑处理
- Redis-集群
猜你喜欢

Evaluate:huggingface评价指标模块入门详细介绍

Comparative analysis of restcloud ETL and kettle

High frequency interview 𞓜 Flink Shuangliu join

【TcaplusDB知识库】TcaplusDB单据受理-事务执行介绍

【C语言练习——打印空心上三角及其变形】

Don't remove custom line breaks on reformat
![[tcapulusdb knowledge base] tcapulusdb doc acceptance - table creation approval introduction](/img/66/f3ab0514d691967ad88535ae1448c1.png)
[tcapulusdb knowledge base] tcapulusdb doc acceptance - table creation approval introduction

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

数据库-完整性约束
![[CEPH] cephfs internal implementation (II): example -- undigested](/img/87/6eb214550faf1f0500565c1610ff3b.png)
[CEPH] cephfs internal implementation (II): example -- undigested
随机推荐
Summer camp is coming!!! Chongchongchong
【TcaplusDB知识库】TcaplusDB单据受理-创建游戏区介绍
Unity C # e-learning (10) -- unitywebrequest (1)
[tcapulusdb knowledge base] tcapulusdb doc acceptance - Introduction to creating game area
【ceph】CephFS 内部实现(四):MDS是如何启动的?--未消化
乐鑫 AWS IoT ExpressLink 模组达到通用可用性
编译配置in文件
夏令营来啦!!!冲冲冲
Inaccurate data accuracy in ETL process
A blog to thoroughly master the theory and practice of particle filter (PF) (matlab version)
The R language cartools package divides data, the scale function scales data, and the KNN function of the class package constructs a k-nearest neighbor classifier
Seurat to h5ad summary
【ceph】CephFS 内部实现(三):快照
/etc/profile、/etc/bashrc、~/. Bashrc differences
【毕业季·进击的技术er】 什么是微信小程序,带你推开小程序的大门
Particle filter PF - 3D CV target tracking with uniform motion (particle filter vs extended Kalman filter)
Applet: uniapp solves vendor JS is too large
Evaluation - TOPSIS
vue中缓存页面 keepAlive使用
Program analysis and Optimization - 8 register allocation