# -*- coding:utf-8 -*-
"""
列印金字塔,隨手寫了個,肯定不是最最佳化的,供參考。
def printGoldTa(input):
L = [chr(i) for i in range(65,91)] ##大寫字母A--Z
idA = 65 #從A開始
idInput = ord(input)
num = idInput - idA + 1 ##A--輸入的字元個數
print "A-->" + input + ":" + str(num)
tempResult =""
for C in range(0,num):
##左 [ABCD]
for C1 in range(0,C):
tempResult = tempResult + L[C1]
## 中 [E]
tempResult = tempResult + L[C]
##右 [DCBA]
for C2 in range(C-1,-1,-1):
tempResult = tempResult + L[C2]
##每行空格
for C3 in range(num-1-C): #
tempResult = " " + tempResult
##輸出
print tempResult
##清空臨時結果
tempResult = ""
#end for
#end def
printGoldTa("E")
printGoldTa("H")
###################
A-->E:5
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
A-->H:8
ABCDEFEDCBA
ABCDEFGFEDCBA
ABCDEFGHGFEDCBA
# -*- coding:utf-8 -*-
"""
列印金字塔,隨手寫了個,肯定不是最最佳化的,供參考。
"""
def printGoldTa(input):
L = [chr(i) for i in range(65,91)] ##大寫字母A--Z
idA = 65 #從A開始
idInput = ord(input)
num = idInput - idA + 1 ##A--輸入的字元個數
print "A-->" + input + ":" + str(num)
tempResult =""
for C in range(0,num):
##左 [ABCD]
for C1 in range(0,C):
tempResult = tempResult + L[C1]
## 中 [E]
tempResult = tempResult + L[C]
##右 [DCBA]
for C2 in range(C-1,-1,-1):
tempResult = tempResult + L[C2]
##每行空格
for C3 in range(num-1-C): #
tempResult = " " + tempResult
##輸出
print tempResult
##清空臨時結果
tempResult = ""
#end for
#end def
printGoldTa("E")
printGoldTa("H")
###################
A-->E:5
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
A-->H:8
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDEFEDCBA
ABCDEFGFEDCBA
ABCDEFGHGFEDCBA