2 !!DESCRIPTION!! solves the "towers of hanoi" problem
3 !!ORIGIN!! BYTE UNIX Benchmarks
4 !!LICENCE!! Public Domain
7 /*******************************************************************************
8 * The BYTE UNIX Benchmarks - Release 3
9 * Module: hanoi.c SID: 3.3 5/15/91 19:30:20
11 *******************************************************************************
12 * Bug reports, patches, comments, suggestions should be sent to:
14 * Ben Smith, Rick Grehan or Tom Yager
15 * ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
17 *******************************************************************************
19 * $Header: hanoi.c,v 3.5 87/08/06 08:11:14 kenj Exp $
20 * August 28, 1990 - Modified timing routines (ty)
22 ******************************************************************************/
25 /*#define USECMDLINE*/
30 unsigned short iter = 0; /* number of iterations */
34 int disk=5, /* default number of disks */
35 duration=10; /* default time to run test */
37 void mov(unsigned char n,unsigned char f,unsigned char t)
55 printf("%2d: %2d %2d %2d %2d\n",
56 (int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]);
60 int main(int argc,char **argv)
64 printf("Usage: %s [duration] [disks]\n", argv[0]);
69 if(argc > 1) duration = atoi(argv[1]);
70 if(argc > 2) disk = atoi(argv[2]);
74 printf("towers of hanoi\ndisks: %d\n\n",disk);
79 printf("%2d: %2d %2d %2d %2d\n",
80 (int)iter,(int)num[0],(int)num[1],(int)num[2],(int)num[3]);