Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The Challenge #2

Name: Lambda A. Calculus !!wKyoNUUHDOmjW7I 2013-04-22 21:56

CURRENT SUMMARY:
http://dis.4chan.org/read/prog/1366477725/1,6,7,12,43,85,86,91,128,129,130,131,134-139,147,148

CURRENT NUMBER ONE CANDIDATE FOR THE /prog/  AWARD FOR RETOIDATION:
http://dis.4chan.org/read/prog/1366477725/188

CURRENT NUMBER ONE SOFTIE WHO COULDN'T TAKE A FEW INSULTS WITHOUT CRYING LIKE A FAT SISSY WHO WANTS TO CRAWL BACK INTO HIS MOTHER'S WOMB:
http://dis.4chan.org/read/prog/1366477725/196

SO DA BASIC IDEA IS AS FOLLOWS:

You offer a challenge. Any program of moderate size that can be completed by a reasonably skilled programmer in under a few hours. The program must be written with C. The game goes like so:

- You state your challenge along with the criteria for the program you want to write. Some good examples include simple cat, sort, and grep programs.

- I'll accept your challenge, write the program, and upload my code to ideone.com so that the timestamp can be recorded.

- You post your code.

- I post my code.

- If your code's awesome, I leave /prog/ forever with a grin of satisfaction on my face. Otherwise, I keep annoying everyone.

Currently there's one challenge in progress (which you can read about in the current summary). However, any new challenges can certainly be made. Gogo!

Name: Anonymous 2013-04-22 22:09

>>11
#include <stdio.h>
#include <stdlib.h>

enum {
    MINVAL = 0,
    MAXVAL = 500,
    NELEMS = MAXVAL - MINVAL + 1,
    NUMBERS = 1000,
    ZERO_BASED = 1
};

struct node {
    int val;
    struct node *next;
};

struct node *new(int v, struct node *np)
{
    static struct node mem[NUMBERS];
    static int n;

    mem[n].val = v;
    mem[n].next = np;
    return mem + n++;
}

int main(void)
{
    static struct node *a[NELEMS];
    struct node *np;
    int i, r;

    for (i = 0; i < NUMBERS; i++) {
        printf(" %d", (r = 10) + 1);
        a[r] = new(i, a[r]);
    }
    puts("");
    for (i = 0; i < NELEMS; i++)
        for (np = a[i]; np; np = np->next)
            printf(" %d", np->val + !ZERO_BASED);
    puts("");
    return 0;
}

TIMESTAMP: http://ideone.com/S9BEkQ

NEXT CHALLENGER

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List