在路上...

The development of life
我们一直都在努力,有您的支持,将走得更远...

站内搜索: Google

  :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
#if 0

    变态的C表达式

  
        1、局部变量i,是保存在栈上的,没有拷贝!
        2、不要试图编译成汇编代码分析,它们对你理解代码没有什么帮助,这招儿我试过了,后来想想也是不应该有用~
        3、后缀++,和前缀++的求值时间是理解以下程序的另一个关键点。
        4、程序中的注释,也是一些提示。嗯?你觉得它们更像谜语?猜吧。
        5、开动你的脑筋,只有自己想出来的答案,记忆才是最深刻的。
        
#endif

#include <stdio.h>

int
main()
{
    int i;

    i = (i=2)+(i=10); /* 10 + 10 */
    printf("%d\n", i);//20


    i = 1;
    i = (++i)+(i=10); /* 10 + 10 */
    printf("%d\n", i);//20


    i = 1;
    i = (i++)+(i=10); /* 10 + 10 + 1 */
    printf("%d\n", i);//21


    i = 1;
    i += ++i; /* 2 += 2 */
    printf("%d\n", i);//4


    i = 1;
    i += i++; /* 1 += 1 + 1 */
    printf("%d\n", i);//3


    i = 1;
    i = (++i)+(++i); /* 3 + 3 */
    printf("%d \n", i);//6


    i = 1;
    i = (++i)+(i++); /* 2 + 2 + 1 */
    printf("%d\n", i);//5


    i = 1;
    i = (i++)+(++i); /* 2 + 2 + 1 */
    printf("%d\n", i);//5


    i = 1;
    i = (i++)+(i++); /* 1 + 1 + 1 + 1 */
    printf("%d\n", i);//4


    i = 1;
    i = (++i)+(i++, i); /* 3 + 3 */
    printf("%d\n", i);//6


}
posted on 2009-08-27 21:07  palam  阅读(216)  评论(0编辑  收藏  举报