1、题目
根据每⽇⽓温列表,请重新⽣成⼀个列表,对应位置的输⼊是你需要再等待多久温度才会升⾼超过该⽇的天数。如果之后都不会升⾼,请在该位置0来代替
-(NSMutableArray *)getNewArr:(NSArray *)arrWeather{NSMutableArray *arrNew = [NSMutableArray array];for (int i = 0; i< self.arrW.count; i++) {int taget = [self.arrW[i] intValue];if (i+1 >= self.arrW.count) {[arrNew addObject:@0];}for (int j = i+1 ; j<self.arrW.count; j++) {int nub = [self.arrW[j] intValue];if (nub > taget) {int result = j-i;[arrNew addObject:[NSNumber numberWithInt:result]];break;}if (j+1 >= self.arrW.count) {[arrNew addObject:@0];}}}NSLog(@"%@",arrNew);return arrNew;}例子:self.arrW = @[@73, @74, @75, @71, @69, @72, @76, @73];调用:[self getNewArr:self.arrW];结果:(1, 1, 4, 2, 1, 1, 0, 0)
