Marcel Kilgus wrote, on 27/Nov/10 18:16 | Nov27:
Norman Dunbar wrote:
Main() always returns int.
True.
Main always takes two parameters int and char **.
Not true, "int main(void)" is valid according to C99 spec (see chapter
5.1.2.2.1 ;-) )
But in context of the IOCC contest Tobias referred to, basically
everything that compiles is valid (his example doesn't really work in
any case). Though they're usually much worse, this for example is an
actual winning entry from 1988:
main(t,_,a)
char *a;
{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a
)&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_,
t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\
+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\
l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")
:t<-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\
+1 ):0<t?main ( 2, 2 , "%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc \
i...@bk'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}
Guess what it does? Why yes, it prints the complete lyrics of the song
"The Twelve Days of Christmas"! No kidding, I just tried it myself
(the actual entry was a bit differently formatted but in no way more
readable):
"On the first day of Christmas my true love gave to me
a partridge in a pear tree.
[...]
On the twelfth day of Christmas my true love gave to me
twelve drummers drumming, eleven pipers piping, ten lords a-leaping,
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree."
Clever. This reminds me of the winner (and another in the short list)
of a QL User competition to draw a picture. It used data statements and
recursive turtle graphics. They were pigs to get working as the QL User
printer was not set up for the QL. Both are on my BBS (dragon_zip I think).
Tony
--
QBBS (QL fido BBS 2:257/67) +44(0)1442-828255
[email protected] http://firshman.co.uk
Voice: +44(0)1442-828254 Fax: +44(0)1442-828255 Skype: tonyfirshman
TF Services, 29 Longfield Road, TRING, Herts, HP23 4DG
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm