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

边栏推荐
- 论文阅读_ICD编码_MSMN
- 1110 complete binary tree (25 points)
- 1111 online map (30 points)
- [tools run SQL blind note]
- Career planning of counter attacking College Students
- appium1.22.x 版本后的 appium inspector 需单独安装
- Notes | numpy-07 Slice and index
- Three representations of signed numbers: original code, inverse code and complement code
- leetcode452. Detonate the balloon with the minimum number of arrows
- Gbase8s unique index and non unique index
猜你喜欢

appium1.22.x 版本后的 appium inspector 需单独安装

The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article
![[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)

Shallow and first code

JDBC database operation
![[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached](/img/95/833f5ec20207ee5d7e6cdfa7208c5e.jpg)
[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached

SSM framework integration
![[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)
![[set theory] relational power operation (relational power operation | examples of relational power operation | properties of relational power operation)](/img/8b/c10423ee95200a0d94f9fb9dde76eb.jpg)
[set theory] relational power operation (relational power operation | examples of relational power operation | properties of relational power operation)

Celebrate the new year together
随机推荐
Market status and development prospect prediction of the global fire alarm sensor industry in 2022
Thesis reading_ Chinese NLP_ ELECTRA
MySQL master-slave configuration
1103 integer factorization (30 points)
MPM model and ab pressure test
[set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)
Prepare for 2022 and welcome the "golden three silver four". The "summary of Android intermediate and advanced interview questions in 2022" is fresh, so that your big factory interview can go smoothly
"Niuke brush Verilog" part II Verilog advanced challenge
First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
[set theory] relationship properties (common relationship properties | relationship properties examples | relationship operation properties)
[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 prospect prediction of global fermentation acid industry in 2022
1094 the largest generation (25 points)
My first Smartphone
Market status and development prospect prediction of the global autonomous hybrid underwater glider industry in 2022
Cross platform plug-in flutter for displaying local notifications_ local_ notifications
Market status and development prospects of the global IOT active infrared sensor industry in 2022
Without 50W bride price, my girlfriend was forcibly dragged away. What should I do
5-36v input automatic voltage rise and fall PD fast charging scheme drawing 30W low-cost chip
JS dynamic table creation