我送出解答只有#2錯誤 但我測試執行卻失敗
您的程式被監控系統中斷,可能是程式無法正常結束所導致。 Traceback (most recent call last): File "/14350102_b266/code_14350102.py", line 23, in R,C,M=map(int,input().split()) ValueError:...
我的程式碼:
#旋轉函式
def zero():
zeroList=[[None for x in range(R)] for x in range(C)]
for x in range(R):
for y in range(C):
zeroList[y][x]=List[x][C-1-y]
return zeroList
#翻轉函式
def one():
oneList=[[None for x in range(C)] for x in range(R)]
for x in range(R):
for y in range(C):
oneList[x][y]=List[R-1-x][y]
return oneList
#取得輸入資料
R,C,M=map(int,input().split())
List=[None for x in range(R)]
for x in range(R):
List[x]=list(map(int,input().split()))
ListM=list(map(int,input().split()))
#列印第一列輸出
times=0
for x in ListM:
if x==0:
times+=1
if times%2==0:
print(R,C)
else:
print(C,R)
#計算A矩陣
for x in ListM:
if x==0:
zeroList_re=zero()
R,C=C,R
del List
List=[[None for x in range(C)] for y in range(R)]
for n in range(R):
for m in range(C):
List[n][m]=zeroList_re[n][m]
else:
oneList_re=one()
del List
List=[[None for x in range(C)] for y in range(R)]
for n in range(R):
for m in range(C):
List[n][m]=oneList_re[n][m]
for x in range(R):
print(*List[x])
拜託各路大神救救
for x in ListM:
因為要輸出的是原始的矩陣,所以要先從最後一筆操作開始往前面算