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

边栏推荐
- [tools run SQL blind note]
- Wechat applet waterfall flow and pull up to the bottom
- Without 50W bride price, my girlfriend was forcibly dragged away. What should I do
- Learning record of arouter principle
- "Hands on deep learning" pytorch edition Chapter II exercise
- 论文阅读_中文医疗模型_ eHealth
- [research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached
- The programmer resigned and was sentenced to 10 months for deleting the code. JD came home and said that it took 30000 to restore the database. Netizen: This is really a revenge
- RT thread flow notes I startup, schedule, thread
- Sprintf formatter abnormal exit problem
猜你喜欢
![[luatos sensor] 2 air pressure bmp180](/img/88/2a6caa5fec95e54e3fb09c74ba8ae6.jpg)
[luatos sensor] 2 air pressure bmp180

RT thread flow notes I startup, schedule, thread

Oracle SQL table data loss

5-36v input automatic voltage rise and fall PD fast charging scheme drawing 30W low-cost chip

Concurrent operation memory interaction

ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)

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

Compile and decompile GCC common instructions

The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article

Do you know UVs in modeling?
随机推荐
Interface frequency limit access
Market status and development prospect prediction of global fermented plant protein industry in 2022
Messy change of mouse style in win system
The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article
[set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)
Market status and development prospect prediction of the global autonomous hybrid underwater glider industry in 2022
[develop wechat applet local storage with uni app]
Market status and development prospect prediction of global neutral silicone sealant industry in 2022
LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)
The process of browser accessing the website
Valentine's day limited withdrawal guide: for one in 200 million of you
appium1.22.x 版本后的 appium inspector 需单独安装
Actual combat 8051 drives 8-bit nixie tube
ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
My first Smartphone
Shell script -- condition judgment
[research materials] 2021 China's game industry brand report - Download attached
ZABBIX monitoring of lamp architecture (2): ZABBIX basic operation
Huawei personally ended up developing 5g RF chips, breaking the monopoly of Japan and the United States
Market status and development prospect forecast of global heat curing adhesive industry in 2022