| |

VerySource

 Forgot password?
 Register
Search
View: 894|Reply: 7

Help random number problem

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-12-16 23:30:02
| Show all posts |Read mode
Which function in VC is a random number generation function, I used Rand() and SRand() in C, but the effect is not good, I don't know why.
Reply

Use magic Report

0

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-12-17 11:00:01
| Show all posts
What is bad effect?
Reply

Use magic Report

0

Threads

55

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-12-17 14:15:01
| Show all posts
How bad?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-12-17 14:30:01
| Show all posts
srand(time(NULL));
rand();
This effect will be better.
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-12-17 17:15:01
| Show all posts
I used Xiao Xiaoshuai's method, somehow at first a few were okay, but later it didn't change. Is there any other method?
Reply

Use magic Report

1

Threads

15

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-12-18 06:00:01
| Show all posts
How does the host use it, it can't be the same
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 Invalid IP Address

Post time: 2020-12-18 11:15:02
| Show all posts
You can explore and write one by yourself
int rand(int k)//The content in the function can be written casually, give full play to your imagination
{
if(k%2 == 0)
{
int sk = k*231219 + 323;
return sk/23%6000;
}
else
{
int sk = k*2312 + 6323;
return sk/21%6000;
}

}
rand(rand(rand(time(null))));
Reply

Use magic Report

0

Threads

14

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-12-18 16:15:01
| Show all posts
What effect is not good?
Isn't lz uniformly random?
If not, use mathematical methods to uniformly randomize to other random methods (such as normal distribution)
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list