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

/prog/ Challenge 9001

Name: Anonymous 2011-05-01 19:51

The correct title of this article is /prog/ Challenge 9001. It appears incorrectly here because of technical restrictions.

The task:

Print numbers from 1 to 1000 without using any loop or conditional statements. Don't just write the printf() or cout statement 1000 times.

inb4 lipthfags and dead dogs using some obscure functionality of their obscure languages.

Name: Anonymous 2011-05-02 6:41

>>9 here, still winning, and I'm back for more


#include <iostream>

typedef void (*print_func)(int);

print_func funcs[2];

void print_func1(int x)
{
    std::cout << x << std::endl;
    funcs[x / 1000](x + 1);
}

void print_func2(int x)
{
}

int main()
{
    funcs[0] = print_func1;
    funcs[1] = print_func2;
    print_func1(1);
    std::cin.get();
}

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