当前位置:网站首页>[basic grammar] C language uses for loop to print Pentagram
[basic grammar] C language uses for loop to print Pentagram
2022-07-03 05:05:00 【The beginning of Hongmeng】
This time, we provide you with a C Language print Pentagram code
Catalog
One 、 Realization effect

Print the five pointed star as shown in the figure
First, build a two-dimensional array , Divide the five pointed star into four parts from top to bottom , Use different for The loop statement fills a two-dimensional array * To build the completed Pentagram
Two 、 Complete code
#include <stdio.h>
char wj[15][38];
int main()
{
int i=0, j=0, k, m4, n4;
for (int i = 0; i < 5; i++) // This is the upper corner of the pentagram (4 That's ok )
{
for (int j = 0; j < 18 - i; j++)// Find rules and read spaces in the array
wj[i][j] = ' ';
for (j = 18-i; j <= i + 18; j++)// Find rules and read them in the array *
wj[i][j] = '*';
}
for (i = 5; i < 9; i++) // These are the middle two corners of the pentagram (4 That's ok )
{
for (j = 0; j < 3 * i - 15; j++)
wj[i][j] = ' ';
for (j = 3 * i - 15; j <= 51 - 3 * i; j++)
wj[i][j] = '*';
}
for (i = 9; i < 11; i++) // This is the part where the middle meets the lower part (2 That's ok )
{
for (j = 0; j < 20 - i; j++)
wj[i][j] = ' ';
for (j = 20 - i; j <= 15 + i; j++)
wj[i][j] = '*';
}
for (i = 11; i < 15; i++) // These are the lower two corners of the pentagram (4 That's ok )
{
for (j = 0; j < 20 - i; j++)
wj[i][j] = ' ';
for (j = 20 - i; j <= 49 - 3 * i; j++)
wj[i][j] = '*';
for (j = 50 - 3 * i; j < 3 * i - 14; j++)// The space between the lower two corners
wj[i][j] = ' ';
for (j = 3 * i - 14; j < i + 16; j++)
wj[i][j] = '*';
}
for (i = 0; i < 15; i++)// Loop out the entire two-dimensional character array
{
for (j = 0; j < 38; j++)
printf("%c", wj[i][j]);
printf("\n");
}
}That's all this time , Thank you for taking the time to read my book , Please correct . Welcome to discuss and share your questions or experiences in the comment area , I hope this article can help you , I wish you a happy life !

边栏推荐
- appium1.22.x 版本后的 appium inspector 需单独安装
- My first Smartphone
- Messy change of mouse style in win system
- 1119 pre- and post order traversals (30 points)
- Basic knowledge of reflection (detailed explanation)
- [SQL injection] joint query (the simplest injection method)
- [research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
- Force GCC to compile 32-bit programs on 64 bit platform
- Shallow and first code
- Notes | numpy-08 Advanced index
猜你喜欢

LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)

Review the configuration of vscode to develop golang

How to connect the network: Chapter 2 (Part 1): a life cycle of TCP connection | CSDN creation punch in
![[set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)](/img/34/d195752992f8955bc2a41b4ce751db.jpg)
[set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)

Oracle SQL table data loss

Silent authorization login and registration of wechat applet
![[set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)](/img/c2/87358af6b2b2892a6eceb751b3b60c.jpg)
[set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)

String matching: find a substring in a string

How to connect the network: Chapter 1 CSDN creation punch in

JQ style, element operation, effect, filtering method and transformation, event object
随机推荐
Market status and development prospect prediction of the global fire extinguisher industry in 2022
Sprintf formatter abnormal exit problem
1107 social clusters (30 points)
Esp32-c3 learning and testing WiFi (II. Wi Fi distribution - smart_config mode and BlueIf mode)
leetcode860. Lemonade change
Blog building tool recommendation (text book delivery)
[clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree
动态规划——相关概念,(数塔问题)
"Hands on deep learning" pytorch edition Chapter II exercise
Gbase8s composite index (I)
Ueditor, FCKeditor, kindeditor editor vulnerability
Market status and development prospect prediction of the global fire hose industry in 2022
"Niuke brush Verilog" part II Verilog advanced challenge
Uipath practice (08) - selector
Basic use of Metasploit penetration testing framework
论文阅读_中文医疗模型_ eHealth
Compile and decompile GCC common instructions
[SQL injection point] location and judgment of the injection point
The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article
2022-02-11 daily clock in: problem fine brush