Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

# Changes between Version 1 and Version 2 of TowersOfHanoiExample

Show
Ignore:
Timestamp:
01/03/06 05:49:43 (15 years ago)
Comment:

Updated to use writef, removed "Source" section, and other miscellany.

Unmodified
Removed
Modified
• ## TowersOfHanoiExample

v1 v2
1616 +
1717 + by Brian Waters
18 + edited by Chris Sauls, Jan 2, 2006
1819 +/
1920
20 import std.c.stdio;
21import std.stdio;
2122
22 int main(char[][] args)
23
24     void solve(int from, int aux, int to, int numdiscs)
25     {
26         if (numdiscs == 0)
23int main(char[][] args) {
24  void solve(int from, int aux, int to, int numdiscs) {
25    if (numdiscs == 0)
26      return;
27    solve(from, to, aux, numdiscs - 1);
28    writefln("%d to %d", from, to);
29    solve(aux, from, to, numdiscs - 1);
30    return;
31  }
2732
28
29             return;
30         solve(from, to, aux, numdiscs - 1);
31         printf("%i to %i\n", from, to);
32         solve(aux, from, to, numdiscs - 1);
33         return;
34     }
35
36     solve(1, 2, 3, 7);
37
38     return 0;
33  solve(1, 2, 3, 7);
34  return 0;
3935}
4036}}}
41
42 == Source ==
43
44 || Link || http://www.dsource.org/tutorials/index.php?show_example=132 ||
45 || Posted by || Anonymous ||
46 || Date/Time || Fri Dec 3, 2004 10:44 pm ||