#Python TQC考題606 二維串列行列數
#偷吃步沒用陣列做
rows=eval(input())
cols=eval(input())
for r in range(rows):
for c in range(cols):
print(“%4d” %(c-r),end=””) #不換行
print() #換行

#理解比較透徹的話,確實沒必要用陣列做:

#正統寫法
#使用陣列以及自定義函數
rows=eval(input())
cols=eval(input())
def compute(L):
for r in range(rows):
for c in range(cols):
print(“%4d” %L[r][c],end=””)
#不換行
print() #換行
L=[]
for r in range(rows):
L.append([])
#L有cols個元素,下一行for迴圈開始寫入
for c in range(cols):
L[r].append(c-r)
#L[r]不是L[c]
compute(L)

#第三次做
def compute(lt):
for r in range(rows):
for c in range(cols):
print(“%4d”%lt[r][c],end=””)
print()
#跟內層的迴圈同縮排
rows=eval(input())
cols=eval(input())
lt=[]
for r in range(rows):
lt.append([])
for c in range(cols):
lt[r].append(c-r)
compute(lt)

#直接印就好,跟list根本無關

# c-r :



![Python 如何用pandas.Series.nsmallest() 找到n個與target差距最小的index?再從中找到距離idxmax最近的index?避免誤抓sidelobes的index? targetIdx = (serMean-target_value).abs().nsmallest(n).index.tolist() ;Series切片: .loc[標籤名1:標籤名2] (會含標籤名2) ; .iloc[位置1:位置2] (不含位置2) Python 如何用pandas.Series.nsmallest() 找到n個與target差距最小的index?再從中找到距離idxmax最近的index?避免誤抓sidelobes的index? targetIdx = (serMean-target_value).abs().nsmallest(n).index.tolist() ;Series切片: .loc[標籤名1:標籤名2] (會含標籤名2) ; .iloc[位置1:位置2] (不含位置2)](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2023/02/20230222082954_53.png?quality=90&zoom=2&ssl=1&resize=350%2C233)







近期留言