首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

过后生成任意规则的几个字符

2013-08-01 
随即生成任意规则的几个字符。NSMutableSet *mySet [[NSMutableSet alloc]init]??????? NSArray *myArra

随即生成任意规则的几个字符。

NSMutableSet *mySet = [[NSMutableSet alloc]init];
??????? NSArray *myArray = [[NSArray alloc]initWithObjects:@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",@"i",@"j",@"k",@"l",@"m",@"n",@"o", nil];
??????? for (int i =0; i<4000; i++) {
??????????? int x1 = arc4random() % 25;
??????????? int x2 = arc4random() % 25;
??????????? int x3 = arc4random() % 25;
??????????? int x4 = arc4random() % 25;
??????????? int x5 = arc4random() % 25;
???????????
??????????? NSString *a1 = [myArray objectAtIndex:x1];
??????????? NSString *a2 = [myArray objectAtIndex:x2];
??????????? NSString *a3 = [myArray objectAtIndex:x3];
??????????? NSString *a4 = [myArray objectAtIndex:x4];
??????????? NSString *a5 = [myArray objectAtIndex:x5];
//??????????? NSLog(@"%@%@%@%@%@ \n",a1,a2,a3,a4,a5);
??????????? NSString *tempString = [NSString stringWithFormat:@"%@%@%@%@%@",a1,a2,a3,a4,a5];
??????????? [mySet addObject:tempString];
??????? }
??????? NSLog(@"mySet == %@",mySet);
??????? NSLog(@"mySet.count===%ld",(unsigned long)mySet.count);

热点排行