NSMutableArray *AArr = [NSMutableArray arrayWithObjects:@1,@4,@8,@10,@14,@20, nil];
NSMutableArray *BArr =[NSMutableArray arrayWithObjects:@2,@3,@11,@13,@17, nil] ;
NSMutableArray *CArr = [NSMutableArray array];
for循环
NSInteger k = 0 ;
for (NSInteger i = 0; i < AArr.count; i++) {
[CArr addObject:AArr[i]];
for (NSInteger j = k; j<BArr.count;j++){
k = j;
if (AArr[i]>BArr[j]) {
break;
}else{
if (AArr[i+1]>BArr[j]) {
[CArr addObject:BArr[j]];
}else{
break;
}} } }
打印
for (NSNumber *a in CArr) {
NSLog(@"%@",a);
}
网友评论