Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Floyds-triangle/PHP/floyds-triangle.php
Normal file
17
Task/Floyds-triangle/PHP/floyds-triangle.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
floyds_triangle(5);
|
||||
floyds_triangle(14);
|
||||
|
||||
function floyds_triangle($n) {
|
||||
echo "n = " . $n . "\r\n";
|
||||
|
||||
for($r = 1, $i = 1, $c = 0; $r <= $n; $i++) {
|
||||
$cols = ceil(log10($n*($n-1)/2 + $c + 2));
|
||||
printf("%".$cols."d ", $i);
|
||||
if(++$c == $r) {
|
||||
echo "\r\n";
|
||||
$r++;
|
||||
$c = 0;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue