当前位置:网站首页>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 * 减少
边栏推荐
- C语言:字符逆序
- MUV LUV EXTRA 2019CCPC秦皇岛站J题 KMP
- Codeforces Round #359 (Div. 2) C. Robbers' watch Violent Enumeration
- 2019 Nanchang Internet Competition Question C, Hello 2019
- MVN 中配置flyway mysq
- 一键登陆服务器脚本
- 【机器学习】降维代码练习
- 2017icpc沈阳 G Infinite Fraction Path BFS+剪枝
- 教你更好的使用 idea 2021.2.3
- Exclude null values when Oracle limits
猜你喜欢

一站制造项目及Spark核心面试 ,220808,,,

Important news丨.NET Core 3.1 will end support on December 13 this year

CoCube传感器MPU6050笔记

低成本、大容量、高交互…Polkadot 引领 GameFi 实现新突破

74HC595芯片引脚说明

String类创建的对象在JVM中的内存分配和equals与==的区别

更改Jupyter Notebook默认打开目录

灵活好用的sql monitoring 脚本 part7

LeetCode: 876. The middle node of the linked list —— simple

Tkinter可以选择的颜色
随机推荐
(error) NOAUTH Authentication required.
2019 Nanchang Internet Competition Question C, Hello 2019
Learning Notes---Machine Learning
常用测试用例设计方法之正交实验法详解
高德地图JS - 已知经纬度来获取街道、城市、详细地址等信息
2019南昌网络赛 C题,Hello 2019
redis学习笔记
入门cv必读的10篇baseline论文
【Template】Tree Chain Segmentation P3384
灵活好用的sql monitoring 脚本 part7
Flexible and easy-to-use sql monitoring script part7
Lottie系列一:介绍与使用
【机器学习】支持向量机(SVM)代码练习
SAP ALV data export many of the bugs
74HC595芯片引脚说明
金九银十即将到来,求职套路多,面试指南我来分享~
P1505 [国家集训队]旅游 树链剖分
js数组相关知识复习
SAP ALV 数据导出被截断的bug
jmeter并发数量以及压力机的一些限制