Ich versuche, eine Matrix Determinante Rechner zu machen, aber ich habe irgendwann stecken geblieben. Könnte jemand hier darauf hinweisen, wo das Problem mit meinem Code liegt? würde sehr geschätzt werden.JavaScript Determinant Rechner
<!DOCTYPE html>
<html>
<script>
function det3x3(){
var mat[[],[],[]], i, j, sum, s;
for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++){
s = i*3+j+1;
mat[i][j] = parseFloat(document.getElementById("num" + s).value);
}
sum = mat[0][0]*mat[1][1]*mat[2][2]+mat[1][0]*mat[2][1]*mat[0][3]+mat[2]
[0]*mat[0][1]*mat[1][2]-mat[0][2]*mat[1][1]*mat[2][0]-mat[1][2]*mat[2]
[1]*mat[0][0]-mat[2][2]*mat[0][1]*mat[1][0];
document.getElementById("result").innerHTML=sum;
}
</script>
<body>
<input type="text" id="num1" value="0">
<input type="text" id="num2" value="0">
<input type="text" id="num3" value="0">
<br>
<input type="text" id="num4" value="0">
<input type="text" id="num5" value="0">
<input type="text" id="num6" value="0">
<br>
<input type="text" id="num7" value="0">
<input type="text" id="num8" value="0">
<input type="text" id="num9" value="0">
<br><br>
<button type="button" id="asd" onclick=”det3x3()">calculate</button>
<br><br>
result:
<span id="result"></span>
</body>
</html>
Lets beginnen von 'Onclick = "det3x3()"' – MaxZoom