[C puzzle book] types

#include <stdio.h>
#define PRINT(format,x) printf("x = %"#format"\n",(x))
//how to add the # ????
int integer = 5;
char character = '5';
char *string = "5";

int main(void)
{
    PRINT(d,string); PRINT(d,character); PRINT(d,integer);
    PRINT(d,string); PRINT(c,character); PRINT(c,integer=53);
    PRINT(d,('5'>5));
    {
        int sx = -8;
        unsigned ux = -8;
        PRINT(o, sx); PRINT(o, ux);
        PRINT(o, sx>>3); PRINT(o, ux>>3);
        PRINT(d, sx>>3); PRINT(d, ux>>3);

    }

}
#include <stdio.h>

#define PR(x) printf(#x" = %.8g\t",(double)x)
#define NL putchar('\n')
#define PRINT4(x1,x2,x3,x4) PR(x1); PR(x2); PR(x3); PR(x4); NL

int main(void)
{
    double d;
    float f;
    long l;
    int i;
    i = l = f = d = 100/3; PRINT4(i,l,f,d);
    d = f = l = i = 100/3; PRINT4(i,l,f,d);
    i = l = f = d = 100/3; PRINT4(i,l,f,d);
    d = f = l = i = (double)100/3;
    PRINT4(i,l,f,d);
    i = l = f = d = (double)(100000/3);
    PRINT4(i,l,f,d);
    d = f = l = i = 100000/3;
    PRINT4(i,l,f,d);


}
#include <stdio.h>
#define PR(x) printf(#x" = %g\t",(double)(x))
#define NL putchar('\n')
#define PRINT1(x1) PR(x1); NL
#define PRINT2(x1,x2) PR(x1); PRINT1(x2);

int main(void)
{
    double d=3.2,x;
    int i=2, y;
    x = (x=d/i)*2; PRINT2(x,y);
    y = (x=d/i)*2; PRINT2(x,y);
    x = d*(x=2.5/d); PRINT1(y);
    x = d*(y=((int)2.9+1.1)/d); PRINT2(x,y);
}

转载于:https://www.cnblogs.com/abacuspix/archive/2012/08/09/2630070.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值