问题:
How does this C program work? 这个C程序如何工作?
main(_){_^448&&main(-~_);putchar(--_%64?32|-~7[__TIME__-_/8%8][">'txiZ^(~z?"-48]>>";;;====~$::199"[_*2&8|_/64]/(_&2?1:8)%8&1:10);}
It compiles as it is (tested on gcc 4.6.3
). 它按原样编译(在gcc 4.6.3
上测试)。 It prints the time when compiled. 它打印编译时的时间。 On my system: 在我的系统上:
!! !!!!!! !! !!!!!! !! !!!!!!
!! !! !! !! !! !! !! !!
!! !! !! !! !! !! !! !!
!! !!!!!! !! !! !! !! !! !!!!!!
!! !! !! !! !! !! !!
!! !! !! !! !! !! !!
!! !!!!!! !! !! !! !!!!!!
Source: sykes2 - A clock in one line , sykes2 author hints 资料来源: sykes2 - 一行中的一个时钟 , sykes2作者提示
Some hints: No compile warnings per default. 一些提示:默认情况下没有编译警告。 Compiled with -Wall
, the following warnings are emitted: 使用-Wall
编译,会发出以下警告:
sykes2.c:1:1: warning: return type defaults to ‘int’ [-Wreturn-type]
sykes2.c: In function ‘main’:
sykes2.c:1:14: warning: value computed is not used [-Wunused-value]
sykes2.c:1:1: warning: implicit declaration of function ‘putchar’ [-Wimplicit-function-declaration]
sykes2.c:1:1: warning: suggest parentheses around arithmetic in operand of ‘|’ [-Wparentheses]
sykes2.c:1:1: warning: suggest parentheses around arithmetic in operand of ‘|’ [-Wparentheses]
sykes2.c:1:1: warning: control reaches end of non-void function [-Wreturn-type]
解决方案:
参考一: https://stackoom.com/question/12aXJ/混淆的C代码竞赛-请解释sykes-c参考二: https://oldbug.net/q/12aXJ/Obfuscated-C-Code-Contest-2006-Please-explain-sykes2-c
来源:oschina
链接:https://my.oschina.net/u/4432649/blog/4317096