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

边栏推荐
- 面试被问到了String相关的几道题,你能答上来吗?
- Eye of depth (18) -- partial derivative
- @Detailed explanation of the use of transactional annotation
- feign调用不通问题,JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
- Intelligent trash can (VII) -- Introduction and use of sg90 steering gear (Pico implementation of raspberry pie)
- 动态规划问题(二)
- Develop effective Tao spell
- Advanced area of attack and defense world web masters unserialize3
- Everything you have learned will come in handy at some point in your life (turn)
- 跳表的原理
猜你喜欢

Eye of depth (18) -- partial derivative

Virtual lab basic experiment tutorial -8. Fourier transform (1)

vscode下链接远程服务器安装插件失败、速度慢等解决方法

Newscenter, advanced area of attack and defense world web masters

110道 MySQL面试题及答案 (持续更新)

Recursion / backtracking (Part 2)

【小程序项目开发 -- 京东商城】uni-app 商品分类页面(上)

Servlet operation principle_ API details_ Advanced path of request response construction (servlet_2)

研发效能的道法术器

Samsung asset management (Hong Kong) launched yuancosmos ETF to focus on investing in the future tuyere track
随机推荐
总结:POD与容器的区别
Laravel permission control
Why is it so difficult for the SEC to refuse the application for transferring gray-scale GBTC to spot ETF? What is the attraction of ETF transfer?
MySQL 分库分表及其平滑扩容方案
AutoCAD -- import excel tables into CAD and merge CAD
Event extraction and documentation (2018)
Centos7 install mysql8
@Transactional 注解使用详解
Idea error running 'application' command line is too long solution
Field injection is not recommended solution
Use hutool tool class to operate excel with more empty Sheet1
@Detailed explanation of the use of transactional annotation
Applet waterfall flow, upload pictures, simple use of maps
Okaleido ecological core equity Oka, all in fusion mining mode
动态规划问题(七)
Principle of meter skipping
ACM SIGIR 2022 | interpretation of selected papers of meituan technical team
Event extraction and documentation (2008-2017)
Laravel8 middleware realizes simple permission control
Opencv macro definition