找回密码
 立即注册
搜索
查看: 308|回复: 13

你能猜出这段程序的输出结果吗?

[复制链接]

26

主题

137

回帖

221

积分

海星

积分
221
发表于 2003-2-28 16:50:47 | 显示全部楼层 |阅读模式
你能猜出这段程序的输出结果吗?

许多人都坚信,只要有源代码,他们就总能搞懂代码里所有的玄机。
下面这几行C语言代码就是对这一类人的最大嘲弄:

这只是一段普通的C语言代码罢了。我知道,它也许看上去不那么
好看,似乎这只是一堆无法通过编译的字符垃圾。不过,为什么
你不试一试呢?它的确能通过所有C语言编译器的编译。

我担保你猜不出它的运行结果,试着运行一下,你一定会被输出结
果惊得目瞪口呆。
*********************************************************/

#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);}

26

主题

137

回帖

221

积分

海星

积分
221
 楼主| 发表于 2003-3-1 02:58:04 | 显示全部楼层
答案是:

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

使用道具 举报

26

主题

137

回帖

221

积分

海星

积分
221
 楼主| 发表于 2003-3-1 02:59:27 | 显示全部楼层
很意外吧!

不过,这更说明了程序可读性的重要性!
回复

使用道具 举报

327

主题

3264

回帖

3641

积分

荣誉版主

积分
3641
发表于 2003-3-1 11:37:02 | 显示全部楼层
服了,呵呵!
回复

使用道具 举报

205

主题

2117

回帖

3112

积分

荣誉版主

积分
3112
发表于 2003-3-3 14:41:25 | 显示全部楼层
真是牛X
回复

使用道具 举报

52

主题

96

回帖

195

积分

海星

积分
195
发表于 2003-3-3 14:45:22 | 显示全部楼层
呵呵,有趣!
回复

使用道具 举报

45

主题

1061

回帖

1494

积分

金牌会员

积分
1494
发表于 2003-3-3 20:45:13 | 显示全部楼层

有点神奇!

不过这说明C语言的灵活性和强大!!
回复

使用道具 举报

48

主题

527

回帖

780

积分

荣誉版主

积分
780
发表于 2003-3-4 13:18:55 | 显示全部楼层
我考,谁写的?
回复

使用道具 举报

76

主题

777

回帖

1156

积分

金牌会员

积分
1156
发表于 2003-3-5 13:10:44 | 显示全部楼层
太牛B了!佩服佩服!
回复

使用道具 举报

4

主题

259

回帖

354

积分

中级会员

积分
354
发表于 2003-3-5 21:41:52 | 显示全部楼层
真的很厉害,,,pf
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|海浩社区

GMT+8, 2025-9-21 12:13 , Processed in 0.094188 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表