zoukankan      html  css  js  c++  java
  • [C puzzle book] Preprocessor for C

    #include <stdio.h>
    #define FUDGE(k) k+3.14159
    #define PR(a) printf("a= %d\t",(int)(a))
    #define PRINT(a) PR(a); putchar('\n')
    #define PRINT2(a,b) PR(a); PRINT(b)
    #define PRINT3(a,b,c) PR(a); PRINT2(b,c)
    #define MAX(a,b) (a<b?b:a)
    
    
    int main(void)
    {
        { 
            int x=2;
            PRINT(x*FUDGE(2));
        }
    
        {
            int ce1;
            for(ce1=0;ce1<=100; ce1+=50)
                PRINT2(ce1, 9./5*ce1+32);
        }
    
        {
            int x=1 ,y =2;
            PRINT3(MAX(x++,y),x,y);
            PRINT3(MAX(x++,y),x,y);
        }
    }
    #include <stdio.h>
    #define NEG(a)-a
    #define weeks(mins) (days(mins)/7)
    #define days(mins) (hours(mins)/24)
    #define hours(mins) (mins/60)
    #define mins(secs) (secs/60)
    #define TAB(c,i,oi,t) if(c=='\t')\
            for(t=8-(i-oi-1)%8,oi=i; t; t--)\
            putchar(' ')
    #define PR(a) printf(#a"=%d\t",(int)(a))
    #define PRINT(a) PR(a); putchar('\n')
    
    
    int main(void)
    {
        {
            int x=1;
            PRINT( -NEG(x) );
        }
    
        {
            PRINT(weeks(10080));
            PRINT(days(mins(86400)));
        }
    
        {
            static char input[]="\twihch\tif?";
            char c;
            int i, oldi, temp;
    
            for(oldi=-1,i=0; (c=input[i])!='\0'; i++)
                if (c<' ')
                           TAB(c,i,oldi,temp);
                else 
                    putchar(c);
                putchar('\n');
        }
    }
  • 相关阅读:
    假如
    Find the peace with yourself
    Sep 15th 2018
    Sep 10th 2018
    third party sales process 继续说
    成功设置open live writer
    sublime text2 基本配置及结合Python 环境
    Compmgmtlauncher.exe问题解决方法
    nginx 代理服务器
    vmware之linux不重启添加虚拟硬盘
  • 原文地址:https://www.cnblogs.com/abacuspix/p/2631744.html
Copyright © 2011-2022 走看看