当前位置:网站首页>[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 !

边栏推荐
- 1099 build a binary search tree (30 points)
- 1087 all roads lead to Rome (30 points)
- [research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached
- [research materials] 2022q1 game preferred casual game distribution circular - Download attached
- "Niuke brush Verilog" part II Verilog advanced challenge
- Concurrent operation memory interaction
- Silent authorization login and registration of wechat applet
- Valentine's day limited withdrawal guide: for one in 200 million of you
- Market status and development prospects of the global IOT active infrared sensor industry in 2022
- Automatic voltage rise and fall 5-40v multi string super capacitor charging chip and solution
猜你喜欢

Source insight garbled code solution

Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis
![[luatos sensor] 2 air pressure bmp180](/img/88/2a6caa5fec95e54e3fb09c74ba8ae6.jpg)
[luatos sensor] 2 air pressure bmp180

论文阅读_ICD编码_MSMN

论文阅读_中文医疗模型_ eHealth

JDBC database operation

2022-02-12 daily clock in: problem fine brush

On typescript and grammar

Online VR model display - 3D visual display solution

Three representations of signed numbers: original code, inverse code and complement code
随机推荐
Market status and development prospect prediction of global SoC Test Platform Industry in 2022
Sprintf formatter abnormal exit problem
1106 lowest price in supply chain (25 points)
Based on RFC 3986 (unified resource descriptor (URI): general syntax)
Market status and development prospects of the global automatic tea picker industry in 2022
"Pthread.h" not found problem encountered in compiling GCC
leetcode406. Rebuild the queue based on height
动态规划——相关概念,(数塔问题)
Retirement plan fails, 64 year old programmer starts work again
1114 family property (25 points)
Current market situation and development prospect prediction of global direct energy deposition 3D printer industry in 2022
RT thread flow notes I startup, schedule, thread
5-36v input automatic voltage rise and fall PD fast charging scheme drawing 30W low-cost chip
[backtrader source code analysis 5] rewrite several time number conversion functions in utils with Python
The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article
1115 counting nodes in a BST (30 points)
[PHP vulnerability weak type] basic knowledge, PHP weak equality, error reporting and bypassing
First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
"Niuke brush Verilog" part II Verilog advanced challenge
Objects. Requirenonnull method description