kernelthread.com

Oberon

The Towers of Hanoi as an Objective-C program.

#include <stdio.h> #include <stdlib.h> #import <Foundation/Foundation.h> #import "Hanoi.h" int main (int argc, const char * argv[]) { unsigned long N; Hanoi *h; NSAutoreleasePool *pool; if (argc != 2) { fprintf(stderr, "usage: %s n\n", argv[0]); return 1; } N = (unsigned int)strtoul(argv[1], (char **)0, 10); if (N == LONG_MIN || N == LONG_MAX || N <= 0) { fprintf(stderr, "illegal value for number of disks\n"); exit(2); } pool = [[NSAutoreleasePool alloc] init]; h = [[Hanoi alloc] init]; [h solve:N]; [h release]; [pool release]; return 0; } // Complete source is in the archive ...

Download

hanoi-objc.tar.gz