Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: notesfiles Path: utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!sdcrdcf!hplabs!hp-pcd!hpfclo!jad From: jad@hpfclo.UUCP Newsgroups: net.jokes Subject: Re: Rotation Decoding Message-ID: <42800003@hpfclo.UUCP> Date: Thu, 14-Jun-84 15:55:00 EDT Article-I.D.: hpfclo.42800003 Posted: Thu Jun 14 15:55:00 1984 Date-Received: Sat, 7-Jul-84 04:46:53 EDT References: <1352@uvacs.UUCP> Organization: Hewlett-Packard Fort Collins Systems Division - Fort Collins, CO Lines: 47 Nf-ID: #R:uvacs:-135200:hpfclo:42800003:000:1469 Nf-From: hpfclo!jad Jun 29 14:55:00 1984 > { this is a Pascal Program that explains how to rotate and unrotate } > { a joke for those of you who do not have tr on your own UNIX machine. } A UNIX system with a Pascal compiler but no "tr"? That would be pretty funny ... but in case your system doesn't have tr, how'd you like a couple of C programs which do the same thing? The original Pascal program was 44 lines (admittedly it had a few blank lines and comments), and both C versions I came up with are fewer than 10. By the way, when are the next C obfuscation awards? These certainly wouldn't take it ... I was just wondering ... So, for a little humor relief (on the job?) how about these: /* ---------- */ /* * rot() -- program to rotate stdin by 13 to stdout ... */ # include # include main() { int ch; for (ch=getchar(); ch != EOF ; ch=getchar()) if (isalpha(ch)) if (isupper(ch)) putchar(ch>'M'?ch-13:ch+13); else putchar(ch>'m'?ch-13:ch+13); else putchar(ch); } /* ---------------------------------------------------------------------- */ /* * rot() -- program to rotate stdin by 13 to stdout ... */ # include # include main() { int ch; for (ch=getchar(); ch != EOF ; ch=getchar()) isalpha(ch)? (isupper(ch)? putchar(ch>'M'?ch-13:ch+13):putchar(ch>'m'?ch-13:ch+13)):putchar(ch); } /* ---------- */ I kind of like the second one myself -- nice and readable. -- john -- John Dilley [ihnp4...]!hpfcla!jad