柠檬班学员面试遇到的笔试题!!!
出招吧各位大佬!
柠檬班学员面试遇到的笔试题!!!
出招吧各位大佬!
代码付上,任意整数的阵列,还在公司不能电脑截图
def wan(k):
m=1
n=int((k+1)/2)
for i in range(1,k+1):
if i<=(k+1)/2:
n-=1
print(' '*n+'*'*m)
if i<(k+1)/2:
m+=2
else:
if k%2==0:
m-=2
print(' '*n+'*'*m)
n+=1
else:
n+=1
m-=2
print(' '*n+'*'*m)
wan(6)
if name == 'main':
num = int(input('input a number:'))
newLi = []
li = [x for x in range(1,num,2)]
if num % 2 != 0:
newLi = li + [num] +li[::-1]
else:
newLi = li + li[::-1]
print(newLi)
for i in newLi:
print(i*'*')
欢迎来到testingpai.com!
注册 关于