Last active
December 16, 2015 09:28
-
-
Save brankoajzele/5412688 to your computer and use it in GitHub Desktop.
Loto number generator
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
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) | |
{ | |
@autoreleasepool { | |
/* Loto _x out of _y */ | |
int _x = 7, _y = 39; | |
NSMutableArray *numbers = [[NSMutableArray alloc] init]; | |
while ([numbers count] < _x) { | |
int x = arc4random_uniform(_y + 1); | |
if (x == 0) { continue; } | |
NSNumber *number = [NSNumber numberWithInteger:x]; | |
if ([numbers containsObject:number] == NO) { | |
[numbers addObject:number]; | |
} | |
} | |
NSArray *lotoNumbers = [numbers sortedArrayUsingSelector: @selector(compare:)]; | |
NSLog(@"Numbers %@", lotoNumbers); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment