FIFO
//
// main.m
// Algorithms
//
// Created by yuki on 2017/3/25.
// Copyright ? 2017年 kang.yu.sh. All rights reserved.
//
#import <Foundation/Foundation.h>
static NSMutableArray *list;
void sumalute(){
NSInteger head = 0;
NSInteger tail = list.count - 1 ;
NSMutableArray *SoList = [list mutableCopy];
NSMutableArray *QQList = [NSMutableArray array];
while (head < tail) {
[QQList addObject:SoList[head]];
head ++;
tail++;
[SoList addObject:SoList[head]];
head++;
}
[QQList addObject:SoList[head]];
NSLog(@"QQ>>: %@",QQList);
}
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
list = [NSMutableArray arrayWithCapacity:100];
[list addObjectsFromArray:[NSArray arrayWithObjects:@"6",@"3",@"1",@"7",@"5",@"8",@"9",@"2",@"4", nil]];
sumalute();
NSLog(@"%@",list);
}
return 0;
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者