经常看到这个奇怪的C代码,但不知道怎么解释!

wizardblue 2004-12-14 10:59:55
#include <stdio.h>
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;# \
){nl]!/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(31[a]):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);}
...全文
905 57 打赏 收藏 转发到动态 举报
写回复
用AI写文章
57 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhxx_qs 2004-12-16
  • 打赏
  • 举报
回复
楼主做什么滴?
怎么还经常能看到这种代码?
dove01 2004-12-16
  • 打赏
  • 举报
回复
对啊对啊~~~~上次好象看到有这个比赛的
比看谁写的代码别人读不出来!绝对经典
不过蛮无聊的……实际的都用不上
pzcai 2004-12-16
  • 打赏
  • 举报
回复
呵呵,貌视不规范哦
jackyhubin 2004-12-16
  • 打赏
  • 举报
回复
faint
simpleyu 2004-12-16
  • 打赏
  • 举报
回复
晕,这种冬冬,看不懂。
chuanke 2004-12-16
  • 打赏
  • 举报
回复
今天再看了一下,其实可以这样理解,将它拷贝下来后命名为1.c用VC打开即可编译
看下面:
#include <stdio.h>

char* AAA = "%s %d %d\n";

char*BBB = "@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;# \
){nl]!/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' ')# \
}'+}##(!!/";

char* CCC ="!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry";

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,AAA):9:16:t<0?t<-72?main(_,t,BBB):t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1):0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,CCC),a+1);
}
IS_NOT_NULL 2004-12-16
  • 打赏
  • 举报
回复
厉害
shenli3514 2004-12-16
  • 打赏
  • 举报
回复
怎么加入些语句,使这个程序能够分页输出?
aomeng 2004-12-16
  • 打赏
  • 举报
回复
The Strings
There are 2 major strings in the program. The first one is encrypted with a substitution cypher - the second string is the key of the cypher.
The key string is:
"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"

For an encrypted character at index X in the key, the decrypted value is at index X+31 in the key. So '@' at index 8, decrypts to the character at index 39, 'O'. Notice that '!' (index 0) translates to '\n' (index 31).

The first string in the program - the one encrypted with they cypher is:

"@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;# \
){nl]!/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' ')# \
}'+}##(!!/"

When it is decrypted it looks like this:

"On the /first/second/third/fourth/fifth/sixth/seventh/eigth/ninth/tenth/eleventh/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.

/"

The slashes are not in the cypher key; they are used to divide the encrypted string into a sequence of substrings. One of the functions of the program decrypts and prints the Nth substring in the sequence.

For more on substitution cyphers, you can check out my solver, which I wrote as an example of using STL.



--------------------------------------------------------------------------------

Basic Outline of How it Works
You probably have a good idea of how it works right now:
main(){
for(day = 1; day <= 12; day++) {
decrypt_and_print_substring(0);
decrypt_and_print_substring(day);
decrypt_and_print_substring(13);
for(gift = day; gift >= 1; gift--)
decrypt_and_print_substring(26 - gift);
}
}

Now, the program does not have loops, so both for-loops are done via recursion. It may appear that there are no sequential pieces to the actual code, but there are. For sequential operations the author either uses the comma operator or does multiple function calls in a single line (e.g. main(main(main()) - the inner most call must be done first).

更详细的解释看这里:http://sigbeer.org/~mike/old/virginia/xmassong/
aomeng 2004-12-16
  • 打赏
  • 举报
回复
这么断的程序竟然可以输出这么多东西?奇怪。。

那些用VC编译的兄弟们,你们在CMD 模式下用 cl xx.c 编译就可以了。
yangfasheng 2004-12-16
  • 打赏
  • 举报
回复
好东西不UP!
beethoven007 2004-12-16
  • 打赏
  • 举报
回复
在borlandc下编译有14 个warnning,没有错误,结果就是
chuanke(程序人生) ( ) 信誉:100 2004-12-15 10:55:00 得分: 0


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
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.

On the eigth day of Christmas my true love gave to me
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.

On the ninth day of Christmas my true love gave to me
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.

On the tenth day of Christmas my true love gave to me
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.

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, 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.

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.



beethoven007 2004-12-16
  • 打赏
  • 举报
回复
佩服佩服, 脑袋大了
carambo 2004-12-15
  • 打赏
  • 举报
回复
强呀!
qufan 2004-12-15
  • 打赏
  • 举报
回复
看到有好多个main 应该是不能编译的东西哈
Flood1984 2004-12-15
  • 打赏
  • 举报
回复
不是学C之正途!
xMars 2004-12-15
  • 打赏
  • 举报
回复
弓虽土

女口 其斤 夫 !
口乌 口乎!
darkstar21cn 2004-12-15
  • 打赏
  • 举报
回复
当然是他们手动写的,要是用正则表达式他们就不能算是高手了。
如果写好后,用正则表达式替换,那我也能写出来一两段。
darkstar21cn 2004-12-15
  • 打赏
  • 举报
回复
TO: zzzxxxcccvvv(zxc)
混乱C程序,是有些牛人们,为了证明没有良好的编程风格也能写出好的程序而作的代码。他们的目的就是,让别人看不懂他的代码,而且程序能完成功能。
FlyDayDream 2004-12-15
  • 打赏
  • 举报
回复
真............... T..MD的乱
还是佩服!
加载更多回复(37)

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧