Love丶FFC's Blog
本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印
*****
***
*
***
*****
所谓“沙漏形状”,是指每行输出奇数个符号;各行符号中心对齐;相邻两行符号数差2;符号数先从大到小顺序递减到1,再从小到大顺序递增;首尾符号数相等。
给定任意N个符号,不一定能正好组成一个沙漏。要求打印出的沙漏能用掉尽可能多的符号。
输入在一行给出1个正整数N(≤1000)和一个符号,中间以空格分隔。
首先打印出由给定符号组成的最大的沙漏形状,最后在一行中输出剩下没用掉的符号数。
19 *
*****
***
*
***
*****
2
1.判断所能生成的沙漏的最大层数
2.按顺序输出沙漏
3.对每一行进行左缩进,也就是实现“居中”,满足题目要求的格式
NOA, Symbol = input().split() # 输入符号个数、符号 NOA = int(NOA) # 将字符型转为整型 MaxLayer = 1 # 沙漏的层数 NOA -= 1 # 减去最中间那一层 # 计算最多有几层 while NOA - 2 * (MaxLayer + 2) >= 0: # 所剩符号数可以再延伸2层 NOA -= 2 * (MaxLayer + 2) MaxLayer += 2 NowLayer = MaxLayer # 沙漏上半部 while NowLayer >= 3: String = (MaxLayer - NowLayer) // 2 * ' ' + NowLayer * Symbol # 将每一层都进行左缩进,实现居中 print(String) NowLayer -= 2 print((MaxLayer - NowLayer) // 2 * ' ' + Symbol) # 沙漏中部,左缩进,实现居中 NowLayer = 3 # 沙漏下半部 while NowLayer <= MaxLayer: String = (MaxLayer - NowLayer) // 2 * ' ' + NowLayer * Symbol # 将每一层都进行左缩进,实现居中 print(String) NowLayer += 2 print(NOA) # 输出剩余符号数
Jorcift
Hepatic toxicity 3 rogaine or propecia
cheap louis vuitton online
I just wanted to thank you for the fast service. or simply they look great. I received them a day earlier than expected. themselves I will definitely continue to buy from this site. manner in which I will recommend this site to my friends. Thanks!
cheap louis vuitton online https://www.bestlouisvuittonoutlet.com/
louis vuitton outlet online
I just wanted to thank you for the fast service. or perhaps a they look great. I received them a day earlier than expected. since the I will definitely continue to buy from this site. either way I will recommend this site to my friends. Thanks!
louis vuitton outlet online https://www.louisvuittonsoutletstore.com/
cheap jordans
I just wanted to thank you for the fast service. or they look great. I received them a day earlier than expected. similar to I will definitely continue to buy from this site. blue jays I will recommend this site to my friends. Thanks!
cheap jordans https://www.cheaprealjordan.com/
cheap real jordans
I just wanted to thank you for the fast service. in addition they look great. I received them a day earlier than expected. most notably the I will definitely continue to buy from this site. in either case I will recommend this site to my friends. Thanks!
cheap real jordans https://www.realcheapretrojordanshoes.com/
cheap jordan shoes
Read reviews and was a little hesitant since I had already inputted my order. or perhaps but thank god, I had no issues. appreciate the received item in a timely matter, they are in new condition. direction so happy I made the purchase. Will be definitely be purchasing again.
cheap jordan shoes https://www.cheapjordansstore.com/
authentic cheap jordans
Read reviews and was a little hesitant since I had already inputted my order. and even but thank god, I had no issues. prefer received item in a timely matter, they are in new condition. situation so happy I made the purchase. Will be definitely be purchasing again.
authentic cheap jordans https://www.realjordansretro.com/
cheap jordans for sale
Read reviews and was a little hesitant since I had already inputted my order. or maybe a but thank god, I had no issues. including received item in a timely matter, they are in new condition. manner in which so happy I made the purchase. Will be definitely be purchasing again.
cheap jordans for sale https://www.realjordansshoes.com/
intuido
medicamento priligy estudios clinicos crizotinib and thiothixene both increase QTc interval
intuido
cialis lamictal ilac nedir The great thing about feminism is that as a female, I can weigh in without being told my experience doesn t qualify me to be able to speak generic propecia Anderson Cancer Center, 1515 Holcombe Blvd
IFBlNw
overnight cialis delivery Section of Cardiovascular Diseases, Department of Experimental and Applied Medicine, University of Brescia, Brescia, Italy