//1.創(chuàng)建一個可變數(shù)組
NSMutableArray *mArray = [NSMutableArray arrayWithObjects:@"a",@"b",@"a",@"b",@"a",@"b",@"a",@"b",nil];
NSMutableArray *A = [NSMutableArray array];
NSMutableArray *B = [NSMutableArray array];
for(int i =0; i < mArray.count; i++) {
if(i ?% 2 == 0) {
[A addObject:mArray[i]];
}else{
[B addObject:mArray[i]];
}
}
XPFLog(@"雙數(shù)%@單數(shù)%@", A, B);
打印結(jié)果:
雙數(shù)(
a,
a,
a,
a
)
單數(shù)(
b,
b,
b,
b
)