Another Silly programming puzzle....
Kyle Saunders
kyle at ritcsh.UUCP
Fri Apr 7 06:57:10 AEST 1989
In article <1210 at microsoft.UUCP>, t-iaind at microsoft.UUCP (Iain Davidson) writes:
> (This is my first BIG post, so if you want to flame, flame low and send away)
>
> For those still silly over the LAST puzzle/challange.... here's another one.
>
> Puzzle:
> Write a "simple" program to convert rec.humor (rot13) jokes to
> a output readable by human eyes...
>
C version: (uses redirection/pipes)
#include <studio.h>
main()
{
char c;
while ((c = getchar()) != EOF) {
if ((c >= 'A') && (c <= 'Z'))
c = ((c-'A'+13) % 26) + 'A';
else if ((c >= 'a') && (c <= 'z'))
c = ((c-'a'+13) % 26) + 'a';
putchar(c);
}
}
sh version: (also uses redirection/pipes)
#rot13.sh
#!/bin/sh
tr A-MN-Za-mn-z N-ZA-Mn-za-m
- Kyle Saunders
Computer Science House @ Rochester Institute of Technology
{known.galaxy}!ccicpg!cci632!ritcsh!kyle or kyle%ritcsh at rit.RIT.EDU
More information about the Comp.lang.c
mailing list