/***********************************************************************\ * triangles1.d * * * * Triangle Challenge * * * * First console version * * Calculates the number * * * * by Stewart Gordon * * October 2004 * \***********************************************************************/ import std.stdio; import std.c.stdio; void main() { int n1, n2; char response = 'y'; while (response == 'y' || response == 'Y') { writef("Number of divisions along each edge: "); fflush(stdin); scanf("%d%d", &n1, &n2); writefln("Number of triangles: %d", n1 * n2 * (n1 + n2) / 2); writef("Again? "); fflush(stdin); response = getchar(); } }