Old lady swallowed a fly: Difference between revisions

→‎{{header|C}}: shorter code
(→‎{{header|C}}: shorter code)
Line 4:
Boring, ad hoc dictionary based decompression. The encoder was arguably more interesting, though.
<lang c>#include <stdio.h>
#include <string.h>
 
char *dict[] = {
"\x5""fly,\x6\xc\x1\xa,/That wr\xd""and w\xd"
"\x1\x3,/\x1a\x4\xdThat w\xfw\xft\xeinside her;/\x13;/\x1a"
"and t\xdinside her;\x3\xa\xe\xc\x8 //\x5\x10;/"
"\x4;/How absurd\x19x11\x5x10./\x14;/x2\x1axc\x6x1\xf;/Fancy that,\x19x11\x6xf!/\x15;/\x1a"
"\x7;/What a hog,\x19\x7!/\x16;/\x1a\x7;/\x18how, she\x19\x8;/\x17;/\x1a"
"\x9 \x1\x12;/What\xbhog,\x11\x12;\x3\x12\x4\xf,\x9\x1"
"\x9.../She's dead, of course!/",
"cow,\x6w how s\x13\xb""cow;\x3""cow\x4\x12,\x3\x12\x4\xf,"
"There was an old lady who""\x2""a ", "\x10""d ",
"\x9\x1horse.../She's dead, of course!/",
"fly", "spider", "bird", "cat", "dog", "cow", "horse",
 
" to catch the ", "\x18why she\x2""a ", "\x3 - Perhaps she'll die!//", ",/",
"iggled \x8//\x5", "\x3\x10\x4\xa,\x3\xa\xe""and ", " swallow", "She/S\x2thex13 ",the "\xb\xc",
" to \xf""ch the ", "There was an old lady who""\x2x7""a ", "ed\x10""d xb",
"\x11\x4\xa\x3",
"/I todon't catchkno", the" swallow", "\x18why shes\x2x13\xb""a ", "\x3fly - Perhaps she'll die!//", ",/",
"\x11\x5\xa\x4\xd\x13",
"\x3\xf\x4\x10,\x2\xc", "spider", " a ", "w why", "iggled ",
"\x11\x6\xa\x5\xd\x14",
"\x4""fly;\x6", "spidercat", "bird", "cat to\x7\xb", "dog", "cowhe\x7", "horseed",
"\x11\x7\xa\x6\xd\x15",
"\x11\x8\xa\x7\xd\x16",
"I don't know ", " to\x10 a ", "\x12\x1",
};
 
void write_outwriteout(char *s)
{
while (*s)do {
if (*s ==< '/'32) putcharwriteout('\n'dict[(int)*s]);
else if putchar(*s >== 32)'/' ? '\n' : putchar(*s);
} while (*++s);
else write_out(dict[(int)*s]);
 
s++;
}
}
 
int main()
{
write_outwriteout(dict[0]);
return 0;
}</lang>
 
=={{header|PHP}}==
{{incorrect|PHP|The program does not produce the correct lyrics. (See talk page)}}
Anonymous user