Annotation of 42BSD/usr.lib/learn/C/L32.1a, revision 1.1

1.1     ! root        1: #print
        !             2: Write a program
        !             3:    pair(a,b)
        !             4: which accepts as arguments two pointers to integers
        !             5: and swaps the integers if necessary so that the
        !             6: first argument points to the larger one; that is
        !             7:        int x,y;
        !             8:        x = 9;
        !             9:        y = 15;
        !            10:        pair( &x, &y);
        !            11: results in x being 15 and y 9.  Leave the program
        !            12: on file "pair.c"; compile, test it, and type "ready".
        !            13: #once #create tzaqc.c
        !            14: main()
        !            15: {
        !            16:        int x,y;
        !            17: 
        !            18:        y=200;
        !            19:        x = 0;
        !            20:        pair(&y, &x);
        !            21:        if (x != 0 || y != 200) 
        !            22:                return(1);
        !            23:        pair(&x,&y);
        !            24:        if (x != 200 || y != 0) 
        !            25:                return(1);
        !            26:        x = 30;
        !            27:        y = 23097;
        !            28:        pair(&x,&y);
        !            29:        if (x != 23097 || y !=  30) 
        !            30:                return(1);
        !            31:        return(0);
        !            32: }
        !            33: #user
        !            34: cc tzaqc.c pair.o
        !            35: a.out 
        !            36: #succeed
        !            37: pair(a, b)
        !            38: int *a, *b;
        !            39: {
        !            40:        int t;
        !            41: 
        !            42:        if (*a <= *b) {
        !            43:                t = *a;
        !            44:                *a = *b;
        !            45:                *b = t;
        !            46:        }
        !            47: }
        !            48: #log
        !            49: #next
        !            50: 33.1a 10

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.