Linux和mac下常规的命令
没错,亲爱的博主大大又来写防忘文了,主要记录一些常用的命令或者开发小技巧......长期更新.......
- terminal 下进入了python vim怎么退出来?
quit() 或者exit()
彩票类app,大乐透选号算法
+(NSArray *)calcuateBallsWithNum:(NSInteger)num andTotalCount:(NSInteger)totalNum{
NSMutableArray *arrT = [NSMutableArray arrayWithCapacity:totalNum];
for (NSInteger i = 1; i<(totalNum+1); i++) {
NSString *a = [NSString stringWithFormat:@"%02ld",(long)i];
[arrT addObject:a];
}
NSMutableArray *arr_balls = [NSMutableArray arrayWithCapacity:num];
for (int i = 0; i<num; i++) {
int x = arc4random()%(totalNum-i);
[arr_balls addObject:[arrT objectAtIndex:x]];
[arrT removeObjectAtIndex:x];
}
return arr_balls;
}
红球35个选5个,篮球12个选2个
_arr_letou = [NSMutableArray arrayWithCapacity:2];
[_arr_letou addObject:[[MLTool calcuateBallsWithNum:5 andTotalCount:35] sortedArrayUsingSelector:@selector(compare:)]];
[_arr_letou addObject:[[MLTool calcuateBallsWithNum:2 andTotalCount:12] sortedArrayUsingSelector:@selector(compare:)]];