Your task is to develop a small part of spreadsheet software.Write a PHP program which adds up columns and rows of given table as shown in the following figure:
Pictorial Presentation:
$m) { $m = (int)$m; $arr[$i][$j] = $m; $arr[$i][$n] += $m; $arr[$n][$j] += $m; } } $arr[$n][$n] = array_sum($arr[$n]); echo "The table with sum of rows and columns:\n"; for ($i = 0; $i <= $n; $i++) { for ($j = 0; $j <= $n; $j++) { printf('%5d', $arr[$i][$j]); } echo PHP_EOL; } } ?>
Sample Input:425 69 51 2668 35 29 5454 57 45 6361 68 47 590
Sample Output:
The table with sum of rows and columns: 25 69 51 26 171 68 35 29 54 186 54 57 45 63 219 61 68 47 59 235 208 229 172 202 811
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Input:
4
25 69 51 26
68 35 29 54
54 57 45 63
61 68 47 59
0
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer