当前位置:网站首页>C language printing diamond
C language printing diamond
2022-07-27 19:15:00 【Annoying】
Ideas : To put it simply , First, we can divide the diamond into the upper half and the lower half , use 3 individual for Cycle through the top half , Reuse 3 individual for Cycle through the bottom half , as for for Why is the judgment condition in the loop written like this , Just remember , Don't ask why , If you ask , It is logical .....
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main() {
int i, j, k;
for (i = 0; i <= 3; i++) { // Control the number of rows in the upper half
for (j = 0; j <= 2 - i; j++) {
printf(" "); // Print spaces by using the correspondence of the number of lines
}
for (k = 0; k <= 2*i; k++) {
printf("*"); // Print the asterisk with the correspondence of the number of lines
}
printf("\n");
}
for (i = 0; i <= 2; i++) { // Control the number of rows in the lower half
for (j = 0; j <= i; j++) {
printf(" "); Print spaces by using the correspondence of the number of lines
}
for (k = 0; k <= 4 - 2 * i; k++) {
printf("*"); // Print the asterisk with the correspondence of the number of lines
}
printf("\n");
}
return 0;
}边栏推荐
- C interface knowledge collection suggestions collection
- Resource for NS2 beginner
- Some advice for NS2 beginner.
- kettle 合并记录 数据减少
- Down sampling - signal phase and aliasing
- WinForm screenshot save C code
- Basic use of Nacos (1) - getting started
- Latex使用--subfigure竖排图形
- Word 2007+ tips
- Study notes of Microcomputer Principles - general integer instructions and Applications
猜你喜欢

200行代码快速入门文档型数据库MonogoDB

Docker - docker installation, MySQL installation on docker, and project deployment on docker

sql 字段类型转换

阿里云对象存储OSS的开通和使用

Blog Garden beautification tutorial

Big enemies, how to correctly choose the intended enterprises in the new testing industry?

kettle EXCEL 累计输出数据

Kinect for Unity3d----KinectManager

进行接口测试时,连接数据库,对数据源进行备份、还原、验证操作

Unity learning notes (rigid body physics collider trigger)
随机推荐
自控原理学习笔记-系统稳定性分析(2)-环路分析及Nyquist-Bode判据
normal distribution, lognormal distribution,正态随机数的生成
Nacos的基本使用(1)——入门
win10小技巧(1)——转移桌面位置
Basic concepts of Nacos and single machine deployment
Latex use - control the display position of tables or graphics
Definition of graph traversal and depth first search and breadth first search (2)
SSM integration
An experience
idea优化小攻略
JS common utils encapsulation
Role authorization --- complete the addition and deletion of secondary menus by adding and deleting primary menus
功率单位(power control)
MySQL learning notes (2) -- stored procedures and stored functions
Performance analysis of continuous time system (1) - performance index and first and second order analysis of control system
Some advice for NS2 beginner.
收下这份实操案例,还怕不会用Jmeter接口测试工具
2022 Ningde Vocational College Teachers' practical teaching ability improvement training - network construction and management
一个经验
图的遍历的定义以及深度优先搜索和广度优先搜索(二)