NSArray *array = [NSArray arrayWithObjects:@"1", @"2" , @"3", @"4" ,@"5" ,@"6" ,@"7" ,@"8" ,@"9" ,@"10" ,@"11" ,@"12" ,@"13" ,@"14" ,@"15" ,@"16" ,@"17" ,@"18" ,@"19" ,nil];
//算法核心代码 数组的对称遍历
NSInteger count = array.count;
int index = (int)count / 2;
int j = index;
for (int i = 0; i < count; i++) {
NSLog(@"%d = %@", i, array[j]);
if (i % 2) {
int k = (i+1) / 2;
j = index + k;
}
else {
int k = (i+2) / 2;
j = index - k;
}
}