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

Random numbers (c++)

Name: Anonymous 2010-11-06 18:51

I need help

Name: Anonymous 2010-11-07 6:31

>>11
It's actually possible to implement it:

#include <stdio.h>
struct GoesTo
{
    int value;

    GoesTo& operator--(int){return *this;}

    bool operator>(int other){
        if(value == other) return false;
        value += (value < other) * 2 - 1;
        return true;
    }
};

int main()
{
    GoesTo i;
    i.value = 0;
    while(i --> 10){ printf("%d ", i.value); }
    while(i --> 0){ printf("%d ", i.value); }
    puts("");
    return 0;
}

Outputs:
1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 0

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