当前位置:网站首页>C: print the diamond
C: print the diamond
2022-08-09 07:45:00 【Gaoyou wu is less】
题目链接:菱形图案
#include<stdio.h>
int main()
{
//多组输入
int n = 0;
while ((scanf("%d", &n) != EOF))
{
int i = 0;
int j = 0;
//triangle above
for (i = 0;i < n;i++)
{
for (j = 0;j < n - i;j++)
{
printf(" ");
}
for (j = 0;j < i + 1;j++)
{
printf("* ");
}
printf("\n");
}
//A line in the middle
for (i = 0;i < n + 1;i++)
{
printf("* ");
}
printf("\n");
//triangle below
for (i = 0;i < n;i++)
{
for (j = 0;j < i + 1;j++)
{
printf(" ");
}
for (j = 0;j < n-i;j++)//每行打印的*Decrement line by line
{
printf("* ");
}
printf("\n");
}
}
return 0;
}
思路:The rhombus can be divided into3个部分,上三角,A horizontal line in the middle,下三角.
The only difference between the upper triangle and the lower triangle is that each row of the upper triangle * 增加,Lower triangle for each row * 减少
边栏推荐
- Apache POI
- web自动化测试有哪些工具和框架?
- tianqf的解题思路
- 【Reprint】Deep Learning (deep learning) study notes arrangement
- 2017 G icpc shenyang Infinite Fraction Path BFS + pruning
- ImportError: cannot import name ‘imresize‘
- Difference Constraint - Graph Theory
- The String class objects created by the JVM memory allocation and the difference between equals and = =
- 训练好的深度学习模型,多种部署方式
- 更改Jupyter Notebook默认打开目录
猜你喜欢
随机推荐
jmeter concurrency and some limitations of the press
SiamFC:用于目标跟踪的全卷积孪生网络 fully-convolutional siamese networks for object tracking
View log common commands
4.MySQL更新和删除数据
用tensorflow.keras模块化搭建神经网络模型
EXCEL使用函数联调(find,mid,vlookup,xlookup)
Colors that Tkinter can choose from
毕业我选择了保家卫国,退伍我选择了华为外包
排序第一节——插入排序(直接插入排序+希尔排序)(视频讲解26分钟)
2042. 检查句子中的数字是否递增
【报错】Root Cause com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
高德地图JS - 已知经纬度来获取街道、城市、详细地址等信息
Pytorch中 nn.BatchNorm2d() 归一化操作
更改Jupyter Notebook默认打开目录
Pytorch 训练技巧
我的创作纪念日
Luogu P1110 report statistics multiset stl good question
种子数据报错:liquibase.exception.ValidationFailedException: Validation Failed
HDU - 3183 A Magic Lamp 线段树
Codeforces Round #359 (Div. 2) C. Robbers' watch Violent Enumeration