此时此刻没有想法,顺手写的,可能有很多bug,欢迎指正。。。
-(BOOL)suibian:(NSArray *)array{
NSMutableArray *tempArr = [NSMutableArray array];
NSMutableArray *tempArr2 = [NSMutableArray array];
for (int i = 1; i < array.count; i ++) {
if ([array[i] integerValue] > [array[i - 1] integerValue] ) {
NSInteger max = [array[i] integerValue];
NSInteger min = [array[i - 1] integerValue];
if (max - min == 1) {
[tempArr addObject:@"yes"];
}
}
}
for (int i = 1; i < array.count; i ++) {
if ([array[i] integerValue] < [array[i - 1] integerValue] ) {
NSInteger max = [array[i - 1] integerValue];
NSInteger min = [array[i] integerValue];
if (max - min == 1) {
[tempArr2 addObject:@"yes"];
}
}
}
if (tempArr.count == 5 || tempArr2.count == 5) {
return YES;
}else{
return NO;
}
}
网友评论