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

边栏推荐
- On typescript and grammar
- Use posture of sudo right raising vulnerability in actual combat (cve-2021-3156)
- [set theory] relational power operation (relational power operation | examples of relational power operation | properties of relational power operation)
- Do you know UVs in modeling?
- Learning record of arouter principle
- Current market situation and development prospect forecast of global UV sensitive resin 3D printer industry in 2022
- leetcode452. Detonate the balloon with the minimum number of arrows
- [batch dos-cmd command - summary and summary] - CMD window setting and operation command - close CMD window and exit CMD environment (exit, exit /b, goto: EOF)
- Market status and development prospects of the global autonomous marine glider industry in 2022
- Market status and development prospects of the global automatic tea picker industry in 2022
猜你喜欢

Cross platform plug-in flutter for displaying local notifications_ local_ notifications

How to connect the network: Chapter 2 (Part 1): a life cycle of TCP connection | CSDN creation punch in
![[set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)](/img/c2/87358af6b2b2892a6eceb751b3b60c.jpg)
[set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)

Esp32-c3 learning and testing WiFi (II. Wi Fi distribution - smart_config mode and BlueIf mode)

leetcode406. Rebuild the queue based on height

Without 50W bride price, my girlfriend was forcibly dragged away. What should I do

ZABBIX monitoring of lamp architecture (2): ZABBIX basic operation
![[clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree](/img/0f/bc8c44aee7a2c9dccac050b1060017.jpg)
[clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree

Unity tool Luban learning notes 1
![[batch dos-cmd command - summary and summary] - CMD window setting and operation command - close CMD window and exit CMD environment (exit, exit /b, goto: EOF)](/img/ce/d6f4fb30727e7436b6443537429ad4.png)
[batch dos-cmd command - summary and summary] - CMD window setting and operation command - close CMD window and exit CMD environment (exit, exit /b, goto: EOF)
随机推荐
Compile and decompile GCC common instructions
Analysis of proxy usage of ES6 new feature
ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
Flutter monitors volume to realize waveform visualization of audio
Preparation for school and professional cognition
Thesis reading_ Chinese NLP_ ELECTRA
Thesis reading_ ICD code_ MSMN
Handler understands the record
112 stucked keyboard (20 points)
Realize file download through the tag of < a > and customize the file name
String matching: find a substring in a string
Notes | numpy-08 Advanced index
[backtrader source code analysis 4] use Python to rewrite the first function of backtrader: time2num, which improves the efficiency by 2.2 times
leetcode860. Lemonade change
并发操作-内存交互操作
Thesis reading_ Chinese medical model_ eHealth
1094 the largest generation (25 points)
2022-02-11 daily clock in: problem fine brush
M1 Pro install redis
Notes | numpy-07 Slice and index