Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Floyds-triangle/D/floyds-triangle.d
Normal file
16
Task/Floyds-triangle/D/floyds-triangle.d
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import std.stdio, std.conv;
|
||||
|
||||
void floydTriangle(in uint n) {
|
||||
immutable lowerLeftCorner = n * (n - 1) / 2 + 1;
|
||||
foreach (r; 0 .. n)
|
||||
foreach (c; 0 .. r + 1)
|
||||
writef("%*d%c",
|
||||
text(lowerLeftCorner + c).length,
|
||||
r * (r + 1) / 2 + c + 1,
|
||||
c == r ? '\n' : ' ');
|
||||
}
|
||||
|
||||
void main() {
|
||||
floydTriangle(5);
|
||||
floydTriangle(14);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue