Created
January 10, 2013 08:34
-
-
Save xuyunan/4500489 to your computer and use it in GitHub Desktop.
随机数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 产生随机数种子 | |
srandom((unsigned)time(NULL)); | |
- (CGPoint)randomPoint | |
{ | |
CGPoint result; | |
NSRect r = [self bounds]; | |
result.x = r.origin.x + random()%(int)r.size.width; | |
result.y = r.origin.y + random()%(int)r.size.height; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment