-(void)creatArray{
NSArray *arr1 = @[@"1",@"3",@"5"];
NSArray *arr2 = @[@"2",@"4",@"6"];
NSMutableArray *arr3 = [[NSMutableArray alloc] init];
for(int i = 0; i < arr1.count; i++){
[arr3 addObject:arr1[i]];
for (int j = 0; j < arr2.count; j++) {
if (i >= j && ![arr3 containsObject:arr2[j]]) {
[arr3 addObject:arr2[j]];
}
}
}
for (int i = 0; i < arr3.count; i++) {
NSLog(@"%@",arr3[i]);
}
}
iOS 交叉合并数组
最新推荐文章于 2021-08-07 21:50:51 发布