Author: Dieter Buerssner
Date: 08:19:19 07/30/03
Go up one level in this thread
On July 30, 2003 at 06:53:43, Uri Blass wrote:
>On July 29, 2003 at 15:31:11, Tord Romstad wrote:
>
>>On July 29, 2003 at 15:17:51, Dann Corbit wrote:
>>
>>>Of course, you can get bizarre in C too (the "C Puzzle Book" is proof enough of
>>>that.) I once had the displeasure of someone giving me a function that was a
>>>64K return statement. He thought it was cute.
>>
>>This is getting increasingly off-topic, but I cannot resist the temptation
>>to post the cutest little C program I have ever seen. It computes an
>>approximation of pi by calculating its own area. :-)
>>
>>
>>/*
>> * Program to compute an approximation of pi
>> * by Brian Westley, 1988
>> * (requires pcc macro concatenation; try gcc -traditional-cpp)
>> */
>>
>>#define _ -F<00||--F-OO--;
>>int F=00,OO=00;
>>main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
>>{
>> _-_-_-_
>> _-_-_-_-_-_-_-_-_
>> _-_-_-_-_-_-_-_-_-_-_-_
>> _-_-_-_-_-_-_-_-_-_-_-_-_-_
>> _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
>> _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
>>_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
>>_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
>>_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
>>_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
>> _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
>> _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
>> _-_-_-_-_-_-_-_-_-_-_-_-_-_
>> _-_-_-_-_-_-_-_-_-_-_-_
>> _-_-_-_-_-_-_-_
>> _-_-_-_
>>}
>
>You know C better than me.
>I do not understand this program
>
>I have define in my program but I do not understand
>
>#define _ -F<00||--F-OO--;
>
>If I understand correctly the computer should replace every _ by
>-F<00||--F-OO--;
>
Yes. And -_ should become --F<00||--F-OO--;
This is not true anymore for a modern implementation of C, where it will become:
- -F<00||--F-OO--;
Anyway, with an old C-preprocessor the first line will give
-F<00||--F-OO--;--F<00||--F-OO--;--F<00||--F-OO--;--F<00||--F-OO--;
Only in the first expression "-F<00||--F-OO--", OO will be decremented. In all
the other expressions, only the left side of the || will be evaluated. So, for
each source code line, OO will be decremented by one, and is therefore the
negative diameter of the circle in the source. For any _ in the source, F will
be decremented, and is therefore the negative area of the source.
The usage of "foo"-like looking expressions my be another "joke" of the source.
Also the fact, that OO and 00 look very similar.
Regards,
Dieter
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.