当前位置:网站首页>PTA (daily question) 7-70 diamond
PTA (daily question) 7-70 diamond
2022-07-29 00:22:00 【Little Deng programmer who can write bugs】
Enter an integer n, Output 2n-1 A diamond formed by rows , for example ,n=5 The diamond of is shown in the output sample .
Input format :
There are multiple sets of test data , Processing to the end of the file . Enter an integer for each set of tests n(3≤n≤20).
Output format :
For each group of test data , Output a total of 2n-1 Diamond of line , See the output example for details .
sample input :
5
sample output :
*
***
*****
*******
*********
*******
*****
***
*
Code :
try:
while True:
n = int(input())
for i in range(1, n+1):
for j in range(n-i):
print(' ', end='')
for k in range(2*i-1):
print('*', end='')
print()
for i in range(1,n):
for j in range(i):
print(' ', end='')
for k in range(2*(n-i)-1):
print('*', end='')
print()
except EOFError:
pass

边栏推荐
- What does WGet mean
- 【微服务~Nacos】Nacos服务提供者和服务消费者
- The difference between {} and ${}
- Erc20 Standard Code
- CV instance segmentation model sketch (1)
- 动态规划问题(二)
- Compilation principle research study topic 2 -- recursive descent syntax analysis design principle and Implementation
- Applet waterfall flow, upload pictures, simple use of maps
- flyway的快速入门教程
- Applet verification code login
猜你喜欢

Sword finger offer 64. find 1+2+... +n, logical operator short circuit effect

Leetcode60. permutation sequence

【MySQL系列】MySQL数据库基础

分布式限流 redission RRateLimiter 的使用及原理

Event extraction and documentation (2018)

Attack and defense world web master advanced area web_ php_ include

Install mysql5.7 under Linux, super detailed complete tutorial, and cloud MySQL connection

Leetcode64. Minimum path sum

熊市下PLATO如何通过Elephant Swap,获得溢价收益?
![[small bug diary] Navicat failed to connect to MySQL | MySQL service disappeared | mysqld installation failed (this application cannot run on your computer)](/img/ac/f63e370df72ace484a618cf946d4b7.png)
[small bug diary] Navicat failed to connect to MySQL | MySQL service disappeared | mysqld installation failed (this application cannot run on your computer)
随机推荐
[MySQL series] MySQL database foundation
110道 MySQL面试题及答案 (持续更新)
Recursion / backtracking (middle)
时间序列统计分析
Attack and defense world web master advanced area PHP_ rce
Leetcode63. Different paths II
Newscenter, advanced area of attack and defense world web masters
分布式限流 redission RRateLimiter 的使用及原理
Develop effective Tao spell
1331. 数组序号转换 : 简单模拟题
Where is sandbox's confidence in rejecting meta's acquisition of meta universe leader sand?
[applet project development -- JD mall] uni app commodity classification page (first)
Web系统常见安全漏洞介绍及解决方案-CSRF攻击
2022 network security learning route is very detailed, recommended Learning
Servlet运行原理_API详解_请求响应构造进阶之路(Servlet_2)
递归/回溯刷题(中)
curl (7) Failed connect to localhost8080; Connection refused
MySQL installation and configuration tutorial (super detailed, nanny level)
MySQL stored procedure
Dynamic programming problem (1)