import math
line = int(input("矩阵有多少行:",))
row = int(input("矩阵列数:",))
c=1
while c<=line:
exec("listx = input('第"+str(c)+"行:',)")
exec("line"+str(c)+"=[]")
list0 = listx.split(",")
d = 0
while d<=row-1:
exec("line"+str(c)+"+= [int(list0["+str(d)+"])]")
d+=1
exec("print(line"+str(c)+")")
c+=1
exchange = 0
L = 2;R = 0
while L <= row:
try:
exec("judgement = (line"+str(L-1)+"["+str(R)+"]==0)")
except:
break
if judgement:
a = L
while a <= line+1-L :
exec("number = line"+str(a)+"["+str(R)+"]")
if number == 0:
a += 1
else:
print("交换line"+str(L-1)+"和line"+str(a))
exec("linex = line"+str(L-1))
exec("liney = line"+str(a))
exec("line"+str(L-1)+" = liney")
exec("line"+str(a)+" = linex")
a = 100;exchange+=1
if a==100:
pass
elif a == line+2-L:
R+=1
print(" !!!!!!第"+str(R)+ "列全为零")
else:
i = L
while i <= line:
r = R
try:
exec("plus = -(line" + str(i)+"["+str(r)+"])/(line"+str(L-1)+"["+str(r)+"])")
except:
break
print("plus: "+str(plus))
while r <= row-1:
exec("line"+str(i)+"["+str(r)+"]="+"line"+str(i)+"["+str(r)+"]+""line"+str(L-1)+"["+str(r)+"]*plus")
exec("x=line"+str(i)+"["+str(r)+"]"+"-math.ceil(line"+str(i)+"["+str(r)+"])")
exec("y=line"+str(i)+"["+str(r)+"]"+"-math.floor(line"+str(i)+"["+str(r)+"])")
exe1 = (abs(x)<0.000000000001)
exe2 = (abs(y)<0.000000000001)
if exe1:
exec("line"+str(i)+"["+str(r)+"]=math.ceil(line"+str(i)+"["+str(r)+"])")
elif exe2:
exec("line"+str(i)+"["+str(r)+"]=math.floor(line"+str(i)+"["+str(r)+"])")
print("正在处理line"+str(i)+"["+str(r)+"]")
r+=1
exec("print(line"+str(i)+")")
i+=1
print(" ----第"+str(R+1)+"列处理完成")
L+=1;R+=1
L=line;R=row-1
while L>=2:
exec("exer=(line"+str(L)+"["+str(R)+"]==0)")
if not exer:
i=L
while i>=2:
exec("plus=-line"+str(i-1)+"["+str(R)+"]/line"+str(L)+"["+str(R)+"]")
print("plus: "+str(plus))
exec("line"+str(i-1)+"["+str(R)+"]=line"+str(i-1)+"["+str(R)+"]+"+"line"+str(L)+"["+str(R)+"]*plus")
print("正在处理line"+str(i-1)+"["+str(R)+"]")
exec("x=line"+str(i-1)+"["+str(R)+"]"+"-math.ceil(line"+str(i-1)+"["+str(R)+"])")
exec("y=line"+str(i-1)+"["+str(R)+"]"+"-math.floor(line"+str(i-1)+"["+str(R)+"])")
exe1 = (abs(x)<0.000000000001)
exe2 = (abs(y)<0.000000000001)
if exe1:
exec("line"+str(i-1)+"["+str(R)+"]=math.ceil(line"+str(i-1)+"["+str(R)+"])")
elif exe2:
exec("line"+str(i-1)+"["+str(R)+"]=math.floor(line"+str(i-1)+"["+str(R)+"])")
i-=1
print(" ----第"+str(R+1)+"列处理完成")
L-=1;R-=1
else:
a=L-1
while exer:
exec("exer=(line"+str(a)+"["+str(R)+"]==0)")
a-=1
L = a
print()
print()
print()
print("Hermite:")
a=1
while a<=row:
exec("print(line"+str(a)+")")
a+=1
print()
print("行列式: ",end = "")
a=1;A=1
while a<=row:
exec("A=A*line"+str(a)+"["+str(a-1)+"]")
a+=1
A=A*((-1)**exchange)
print(A)
好臃肿的代码
但是是线代作业无所谓啦

被折叠的 条评论
为什么被折叠?



