📜  用几行代码打印圣诞节的12天| xmas.c代码

📅  最后修改于: 2021-05-28 05:01:18             🧑  作者: Mango

“圣诞节的十二天”是一首英国圣诞节特别的颂歌,于1780年代出版,据说这是天主教徒在英国遭受迫害的伊丽莎白女王一世期间藏匿的。它的发明是利用图像作为帮助儿童记忆的工具,在不引起政府官员注意的情况下帮助教给儿童天主教的文章。这首歌代表着圣诞节十二天的每一天所给予的逐步隆重的礼物。圣诞节的十二天是从圣诞节(12月25日)开始的喜庆的日子。这又被称为“ Christmastide”和“ Twelvetide”。

1988年,令人印象深刻且令人敬畏的C代码(名为xmas.c)赢得了国际混淆C代码竞赛的冠军。
该程序甚至比其输出的“压缩”类型还小,因此代表了文本压缩标准的全新突破。评委们认为,通过随意敲打一台老式打字机的按键,该程序听起来像您会得到的。

这可能会一直持续到最后一句话,就是只印出歌词。但是,您明白了。这是我遇到的更好混淆的C程序之一,因为它与递归一起使用了替换密码。然后添加少量不必要的代码,并在不使用自变量的情况下使用随机自变量。一个可爱的C代码小捆绑包!理解正在发生的事情距离编写它还有很长的路要走-这是创造力的一个很好的例子。

传奇的xmas.c代码:

#include 
   
main(int t, char _, 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);
}

输出:

On the first day of Christmas my true love gave to me
a partridge in a pear tree.

On the second day of Christmas my true love gave to me
two turtle doves
and a partridge in a pear tree.

On the third day of Christmas my true love gave to me
three french hens, two turtle doves
and a partridge in a pear tree.

On the fourth day of Christmas my true love gave to me
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

On the fifth day of Christmas my true love gave to me
five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

On the sixth day of Christmas my true love gave to me
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

On the seventh day of Christmas my true love gave to me
sevean swans -swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

On the eighth day of Christmas my true love gave to me
eight maids a-milking, sevean swans -swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

On the ninth day of Christmas my true love gave to me
nine ladies dancing, eight maids a-milking, sevean swans -swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

On the tenth day of Christmas my true love gave to me
ten lords a-leaping,
nine ladies dancing, eight maids a-milking, sevean swans -swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

On the eleventh day of Christmas my true love gave to me
eleven pipers piping, ten lords a-leaping,
nine ladies dancing, eight maids a-milking, sevean swans -swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and 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, sevean swans -swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

想要从精选的最佳视频中学习和练习问题,请查看《基础知识到高级C的C基础课程》。