[C puzzle book] Storage Class

//sc_4.c included file

static int i=10;
int next()
{
    return(i+=1);
}

int last()
{
    return (i-=1);
}


int new(i)
int i;
{
    static int j=5;
    return (i=j+=i);
}

extern int i;
reset()
{
    return (i);
}
#include <stdio.h>

#define PR(format,value) printf(#value"= %"#format"\t",(value))
#define NL putchar('\n')

#define PRINT1(f,x1) PR(f,x1), NL
#define PRINT2(f,x1,x2) PR(f,x1), PRINT1(f,x2)
#define PRINT3(f,x1,x2,x3) PR(f,x1), PRINT2(f,x2,x3)
#define PRINT4(f,x1,x2,x3,x4) PR(f,x1), PRINT3(f,x2,x3,x4)
#include "defs.h"

int i = 0;

int main(void) 
{
    auto int i=1;
    PRINT1(d,i);
    {    int i=2;
        PRINT1(d,i);
        {
            i += 1;
            PRINT1(d,i);
        }
        PRINT1(d,i);
    }
    PRINT1(d,i);
}
#include "defs.h"

#define LOW 0
#define HIGH 5
#define CHANGE 2

int i=LOW;

int main(void)
{
    auto int i=HIGH;
    reset(i/2); PRINT1(d,i);
    reset(i=i/2); PRINT1(d,i);
    i=reset(i/2); PRINT1(d,i);

    workover(i); PRINT1(d,i);
}

workover(i)
int i;
{
    i = (i%i) * ((i*8)/(2*i) + 4);
    PRINT1(d,i);
    return(i);
}

int reset(i)
int i;
{
    i = i <= CHANGE ? HIGH : LOW;
    return (i);
}
    
#include "defs.h"

int i=1;

int main(void)
{
    auto int i,j;
    i = reset();
    for(j=1; j<=3; j++) {
        PRINT2(d,i,j);
        PRINT1(d,next(i));
        PRINT1(d,last(i));
        PRINT1(d,new(i+j));
    }
}
int reset()
{
    return (i);
}

int next(j)
int j;
{
    return (j=i++);
}
#include "defs.h"
#include "sc_file.c"

int i=1;

int main(void)
{
    auto int i, j;

    i=reset();
    for(j=1;j<=3;j++) {
        PRINT2(d,i,j);
        PRINT1(d,next(i));
        PRINT1(d,last(i));
        PRINT1(d,new(i+j));
    }
}
原文地址:https://www.cnblogs.com/abacuspix/p/2630099.html