import os, sys
def buildMatrix (inputList):
# print rowNum, colNum
inputListTrim = inputList[2:]
# print inputListTrim
inputMatrix = []
tmpCount = 0
for tmpRowNum in range(rowNum):
tmpList = []
for tmpColNum in range(colNum):
# print tmpRowNum, tmpColNum, tmpCount
tmpList.append(inputListTrim[tmpCount])
tmpCount += 1
inputMatrix.append(tmpList)
return inputMatrix
def outputMatrix (inputMatrix):
inputMatrixBuf = inputMatrix
outputList = []
while (len(inputMatrixBuf) > 0):
tmpList = []
tmpList = [tmpStr for tmpStr in inputMatrixBuf[0]]
inputMatrixBuf = inputMatrixBuf[1:]
outputList += tmpList
if (len(inputMatrixBuf) == 0):
break
tmpList = []
for tmpCount in range(len(inputMatrixBuf)):
tmpList.append(inputMatrixBuf[tmpCount].pop())
outputList += tmpList
if (len(inputMatrixBuf) == 0):
break
tmpList = []
tmpListBuf = []
tmpListBuf = reversed(inputMatrixBuf[-1])
tmpList = [tmpStr for tmpStr in tmpListBuf]
inputMatrixBuf = inputMatrixBuf[:-1]
outputList += tmpList
if (len(inputMatrixBuf) == 0):
break
tmpList = []
for tmpCount in range((len(inputMatrixBuf) – 1), -1, -1):
tmpList.append(inputMatrixBuf[tmpCount][0])
inputMatrixBuf[tmpCount] = inputMatrixBuf[tmpCount][1:]
outputList += tmpList
# print inputMatrixBuf
return outputList
inputListStr = raw_input(“Input:\n”)
inputList = inputListStr.split()
#print inputList
if (len(inputList) < 2):
sys.exit(“Could not got row & col numbers!”)
rowNum = int(inputList[0])
colNum = int(inputList[1])
if ((rowNum * colNum) != (len(inputList) – 2)):
sys.exit(“Wrong Arguments Number!”)
inputMatrix = buildMatrix(inputList)
#print inputMatrix
outputList = outputMatrix(inputMatrix)
print “output:”
print ” “.join(outputList)
说实话,百度推广,部分图片真粗糙,还有,你是不是代码放错了?怎么帖子乱了。。。昨天还是好好的
額..Google的廣告被停了