The for
Loop
-
import std.stdio; void main() { for (int line = 0; line != 9; ++line) { for (int column = 0; column != 9; ++column) { write(line, ',', column, ' '); } writeln(); } }
- Triangle:
import std.stdio; void main() { for (int line = 0; line != 5; ++line) { int length = line + 1; for (int i = 0; i != length; ++i) { write('*'); } writeln(); } }
Parallellogram:
import std.stdio; void main() { for (int line = 0; line != 5; ++line) { for (int i = 0; i != line; ++i) { write(' '); } writeln("********"); } }
Can you produce the diamond pattern?
* *** ***** ******* ***** *** *