G
greenflame
a = [
[1,2],
[3,4]
]
b = [
[5,6],
[7,8]
]
function addarr(A,B) {
C = A;
for (i=0;i<A.length;i++) {
for (j=0;j<A[0].length;j++) {
C[j] = A[j] + B[j];
}
}
}
function show(input) {
for (i=0;i<input.length;i++) {
switch (i) {
case 0:
document.write("<font face=symbol>é</font>");
break;
case input.length-1:
document.write("<font face=symbol>ë</font>");
break;
default: document.write("<font face=symbol>ê</font>");
}
for (j=0;j<input.length-1;j++) {
document.write(input[j] + " ");
}
document.write(input[input.length-1]);
switch (i) {
case 0:
document.write("<font face=symbol>ù</font>");
break;
case input.length-1:
document.write("<font face=symbol>û</font>");
break;
default: document.write("<font face=symbol>ï</font>");
}
document.write("<br>");
}
}
c = addarr(a,b);
show(c);
This code shows absolutely nothing. This code is supposed to show the
sum of the following matricies.
a = [1 2]
[3 4]
b = [5 6]
[7 8]
The sum of two matricies is the sum of the corresponding elements. Thus
the matrix c should be:
c = [6 8 ]
[10 12]
[1,2],
[3,4]
]
b = [
[5,6],
[7,8]
]
function addarr(A,B) {
C = A;
for (i=0;i<A.length;i++) {
for (j=0;j<A[0].length;j++) {
C[j] = A[j] + B[j];
}
}
}
function show(input) {
for (i=0;i<input.length;i++) {
switch (i) {
case 0:
document.write("<font face=symbol>é</font>");
break;
case input.length-1:
document.write("<font face=symbol>ë</font>");
break;
default: document.write("<font face=symbol>ê</font>");
}
for (j=0;j<input.length-1;j++) {
document.write(input[j] + " ");
}
document.write(input[input.length-1]);
switch (i) {
case 0:
document.write("<font face=symbol>ù</font>");
break;
case input.length-1:
document.write("<font face=symbol>û</font>");
break;
default: document.write("<font face=symbol>ï</font>");
}
document.write("<br>");
}
}
c = addarr(a,b);
show(c);
This code shows absolutely nothing. This code is supposed to show the
sum of the following matricies.
a = [1 2]
[3 4]
b = [5 6]
[7 8]
The sum of two matricies is the sum of the corresponding elements. Thus
the matrix c should be:
c = [6 8 ]
[10 12]