1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | $shit = [5.0,-4.0,-6.0,21.0,-2.0,3.0,4.0,-15.0,3.0,-7.0,-5.0,15.0] puts "------------=========== step1 ===========------------" puts "Solving" puts "┌#{$shit[0]}x+#{$shit[1]}y+#{$shit[2]}z=#{$shit[3]}" puts "├#{$shit[4]}x+#{$shit[5]}y+#{$shit[6]}z=#{$shit[7]}" puts "└#{$shit[8]}x+#{$shit[9]}y+#{$shit[10]}z=#{$shit[11]}" puts "------------===========step2-1===========------------" puts "Ans:" puts "#{$shit[0]*$shit[4]}x+#{$shit[1]*$shit[4]}y+#{$shit[2]*$shit[4]}z=#{$shit[3]*$shit[4]}" puts "-#{$shit[0]*$shit[4]}x-#{$shit[0]*$shit[5]}y-#{$shit[0]*$shit[6]}z=-#{$shit[0]*$shit[7]}" puts "-----------------------------------------------------" puts "#{($shit[1]*$shit[4])-($shit[0]*$shit[5])}y+#{($shit[2]*$shit[4])-($shit[0]*$shit[6])}z=#{($shit[3]*$shit[4])-($shit[0]*$shit[7])}" puts "------------===========step2-2===========------------" puts "#{$shit[8]*$shit[4]}x+#{$shit[5]*$shit[8]}y+#{$shit[6]*$shit[8]}z=#{$shit[7]*$shit[8]}" puts "#{$shit[8]*$shit[4]}x+#{$shit[9]*$shit[4]}y+#{$shit[10]*$shit[4]}z=#{$shit[11]*$shit[4]}" puts "-----------------------------------------------------" puts "#{($shit[5]*$shit[8])-($shit[9]*$shit[4])}y+#{($shit[6]*$shit[8])-($shit[10]*$shit[4])}z=#{($shit[7]*$shit[8])-($shit[11]*$shit[4])}" puts "------------=========== step3 ===========------------" puts "Now we have:" puts "┌#{($shit[1]*$shit[4])-($shit[0]*$shit[5])}y+#{($shit[2]*$shit[4])-($shit[0]*$shit[6])}z=#{($shit[3]*$shit[4])-($shit[0]*$shit[7])}" puts "└#{($shit[5]*$shit[8])-($shit[9]*$shit[4])}y+#{($shit[6]*$shit[8])-($shit[10]*$shit[4])}z=#{($shit[7]*$shit[8])-($shit[11]*$shit[4])}" puts "#{(($shit[1]*$shit[4])-($shit[0]*$shit[5]))*(($shit[5]*$shit[8])-($shit[9]*$shit[4]))}y+#{(($shit[2]*$shit[4])-($shit[0]*$shit[6]))*(($shit[5]*$shit[8])-($shit[9]*$shit[4]))}z=#{(($shit[3]*$shit[4])-($shit[0]*$shit[7]))*(($shit[5]*$shit[8])-($shit[9]*$shit[4]))}" puts "-#{(($shit[5]*$shit[8])-($shit[9]*$shit[4]))*(($shit[1]*$shit[4])-($shit[0]*$shit[5]))}y-#{(($shit[6]*$shit[8])-($shit[10]*$shit[4]))*(($shit[1]*$shit[4])-($shit[0]*$shit[5]))}z=-#{(($shit[7]*$shit[8])-($shit[11]*$shit[4]))*(($shit[1]*$shit[4])-($shit[0]*$shit[5]))}" puts "-----------------------------------------------------" puts "#{(($shit[2]*$shit[4])-($shit[0]*$shit[6]))*(($shit[5]*$shit[8])-($shit[9]*$shit[4]))-(($shit[6]*$shit[8])-($shit[10]*$shit[4]))*(($shit[1]*$shit[4])-($shit[0]*$shit[5]))}z=#{(($shit[3]*$shit[4])-($shit[0]*$shit[7]))*(($shit[5]*$shit[8])-($shit[9]*$shit[4]))-(($shit[7]*$shit[8])-($shit[11]*$shit[4]))*(($shit[1]*$shit[4])-($shit[0]*$shit[5]))}" puts "z=#{((($shit[3]*$shit[4])-($shit[0]*$shit[7]))*(($shit[5]*$shit[8])-($shit[9]*$shit[4]))-(($shit[7]*$shit[8])-($shit[11]*$shit[4]))*(($shit[1]*$shit[4])-($shit[0]*$shit[5])))/((($shit[2]*$shit[4])-($shit[0]*$shit[6]))*(($shit[5]*$shit[8])-($shit[9]*$shit[4]))-(($shit[6]*$shit[8])-($shit[10]*$shit[4]))*(($shit[1]*$shit[4])-($shit[0]*$shit[5])))}" $z = ((($shit[3]*$shit[4])-($shit[0]*$shit[7]))*(($shit[5]*$shit[8])-($shit[9]*$shit[4]))-(($shit[7]*$shit[8])-($shit[11]*$shit[4]))*(($shit[1]*$shit[4])-($shit[0]*$shit[5])))/((($shit[2]*$shit[4])-($shit[0]*$shit[6]))*(($shit[5]*$shit[8])-($shit[9]*$shit[4]))-(($shit[6]*$shit[8])-($shit[10]*$shit[4]))*(($shit[1]*$shit[4])-($shit[0]*$shit[5]))) puts "Now we have z=#{$z}, start solving for y" puts "------------=========== step4 ===========------------" puts "#{($shit[1]*$shit[4])-($shit[0]*$shit[5])}y+#{($shit[2]*$shit[4])-($shit[0]*$shit[6])}*#{$z}=#{($shit[3]*$shit[4])-($shit[0]*$shit[7])}" puts "#{($shit[1]*$shit[4])-($shit[0]*$shit[5])}y=#{($shit[3]*$shit[4])-($shit[0]*$shit[7])}-#{(($shit[2]*$shit[4])-($shit[0]*$shit[6]))*$z}" puts "y=#{($shit[3]*$shit[4])-($shit[0]*$shit[7])-((($shit[2]*$shit[4])-($shit[0]*$shit[6])))*$z}/#{($shit[1]*$shit[4])-($shit[0]*$shit[5])}" puts "y=#{(($shit[3]*$shit[4])-($shit[0]*$shit[7])-((($shit[2]*$shit[4])-($shit[0]*$shit[6])))*$z)/(($shit[1]*$shit[4])-($shit[0]*$shit[5]))}" $y = (($shit[3]*$shit[4])-($shit[0]*$shit[7])-((($shit[2]*$shit[4])-($shit[0]*$shit[6])))*$z)/(($shit[1]*$shit[4])-($shit[0]*$shit[5])) puts "Finally, we have y=#{$y} and z=#{$z}. Find the value of x." puts "#{$shit[0]}x+#{$shit[1]}*#{$y}+#{$shit[2]}*#{$z}=#{$shit[3]}" puts "#{$shit[0]}x=#{$shit[3]-$shit[1]*$y-$shit[2]*$z}" puts "x=#{$shit[3]-$shit[1]*$y-$shit[2]*$z}/#{$shit[0]}" puts "x=#{($shit[3]-$shit[1]*$y-$shit[2]*$z)/$shit[0]}" $x = ($shit[3]-$shit[1]*$y-$shit[2]*$z)/$shit[0] puts "==============Finally Ansewer==============" puts "(#{$x},#{$y},#{$z})" puts "==============Problem Solved!==============" |
3元1次方程解决方案——shit!(众:你这笨蛋真是无聊透顶了. .