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

Pages: 1-

Random numbers (c++)

Name: Anonymous 2010-11-06 18:51

I need help

Name: Anonymous 2010-11-06 18:58

rand()

next

Name: Anonymous 2010-11-06 19:01

k im not a programmer, just want to know d how you use random numbers when you need say 100 in just one second

Name: Anonymous 2010-11-06 19:19

halp

Name: Anonymous 2010-11-06 19:25

>>1
C++
Yeah, you do need help. But this isn't an abuse survivors' counseling group.

Name: Anonymous 2010-11-06 19:33

I don't really know c++ so I have no idea if this works or not


#include <cstdlib>
#include <iostream>
int main()
{
    int iLadyBoys[100];
    for (int i = 0; i == 100; 1)
    {
        iLadyBoys[i] = rand();
        cout << iLadyBoys[i];
    }
}

not sure

Name: Anonymous 2010-11-06 19:34

I think 1 should be maybe i++

Name: Anonymous 2010-11-06 19:46

I keep seeing repeating numbers like 1111111111222222222222222244444444444

Name: Anonymous 2010-11-06 21:00

#include <cstdlib>
#include <iostream>

int main()
{
    int iLadyBoys[100];

    for (int i = 0; i < 100; i++)
    {
        iLadyBoys[i] = rand();
        cout << iLadyBoys[i];
    }

    return 0;
}

/* amidonitrite? */

Name: Anonymous 2010-11-06 21:45

>>9
THANK YOU :3

Name: Anonymous 2010-11-06 22:22

int i = 100; while (i --> 0) cout << rand();

Using the wonderful “goes-to” operator, -->.

Name: Anonymous 2010-11-06 23:20

while (i <=> 0)

Name: Anonymous 2010-11-07 6:01

>>3
k im not a programmer
Then what are you doing here?

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

Name: Anonymous 2010-11-07 7:52

>>11
i lold

Name: Anonymous 2010-11-07 8:54

>>14
Great, I'll use this in all my Sepples progra--oh wait.

Name: Anonymous 2010-11-07 9:41

>>14
Should override operator=, too.

Name: Anonymous 2010-11-08 1:35

>>16
Indeed.

Name: Anonymous 2010-11-08 18:01

>>11
Syntactic sugar considered harmful.

Name: Anonymous 2010-11-08 18:57

>>19
considered delicious

Name: Anonymous 2010-11-08 20:14

I use Perl with syntactic [spoiler]salt  .

Name: Anonymous 2010-11-14 5:59

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